Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-03

Daemon - OnStop and OnDestroy events never fired?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

I have daemon on Linux Mint 14 64bit which working fine, but I noticed that OnStop and OnDestroy events are never fired. I created simple test which write to syslog and create file in my home directory:

procedure TTestDaemon.DataModuleStop(Sender: TCustomDaemon; var OK:
Boolean);
var sl: TStringList;
begin
  sl := TStringList.Create;
  try
    sl.Add('test');
    sl.SaveToFile('/home/dibo/s.txt');
  finally
    sl.Free;
  end;
  Application.Log(etInfo, 'Stopping');
end;
procedure TTestDaemon.DataModuleDestroy(Sender: TObject);
var sl: TStringList;
begin
  sl := TStringList.Create;
  try
    sl.Add('test');
    sl.SaveToFile('/home/dibo/d.txt');
  finally
    sl.Free;
  end;
  Application.Log(etInfo, 'destroying');
end;

But these event doesn't add logs in syslog, text file in home directory isn't created also. Is linux blocking disk writting when stopping service? There is also OnShutDown event which is working fine (I finally moved my "clean" methods to this event) but I'm wondering why mentioned events are not fired?

Regards

Michael Van Canneyt
to Krzysztof
Krzysztof wrote
Hi, I have daemon on Linux Mint 14 64bit which working fine, but I noticed that OnStop and OnDestroy events are never fired. I created simple test which write to syslog and create file in my home directory:

How do you stop the service ?

Stop has no meaning on Linux; only shutdown.

Michael.

Michael Van Canneyt
to Krzysztof
Krzysztof wrote
I'm stopping by: sudo service my_script.sh stop.

Yes,

but what signal does that send: SIGTERM probably -> this is a ShutDown.

Michael.