[fpc-pascal] Stopping daemon in linux

Michael Van Canneyt michael at freepascal.org
Mon Nov 9 14:14:36 CET 2009



On Mon, 9 Nov 2009, Joost van der Sluis wrote:

> On Mon, 2009-11-09 at 13:02 +0200, Wimpie Nortje wrote:
>>
>> Michael Van Canneyt wrote:
>>> It should stop the daemons properly. This is the code that gets executed:
>>>
>>> Procedure DoShutDown(Sig : Longint; Info : PSigInfo; Context :
>>> PSigContext);
>>> cdecl;
>>>
>>> begin
>>>   Application.StopDaemons(True);
>>>   Application.Terminate;
>>> end;
>>>
>>> If it doesn't, something is wrong :(
>> I think something is wrong. :(
>>
>> For my TDaemon descendant I assigned the following events:
>> OnDestroy
>> OnExecute
>> OnPause
>> OnShutdown
>> OnStart
>> OnStop
>>
>> When I type "./daemon -r &"
>> The following handlers are executed:
>> 1. OnStart
>> 2. OnExecute
>>
>> When I type "kill -TERM daemon_pid"
>> The following handler is executed
>> 1. OnDestroy
>>
>> I am also a bit confused by the wiki. According to the wiki Start and
>> stop are triggered under linux but shutdown is not. The 'Taming the
>> daemon' article does not specify which of these 3 are called under linux.
>>
>> As I mentioned earlier, I use FPC 2.2.4. Could that be the problem?
>
> I don't know how I did it exactly, but I ahve this working properly in a
> production system. (Even created my own SysV init script for it. It
> should be generally usable for all fpc-daemon applications)

That's good news: I had it on my todo list to let the 'Install' mode generate
this script in the appropriate directory. If I can use your script as a
start, then I can implement that.

Michael.



More information about the fpc-pascal mailing list