TDaemon Wiki Demo : start event not fired lazarus / 1-Linux ---------------------------------------------------------------------- Michael Collier · 2023-02-02 13:05 Hi, I'm experimenting with linux daemons and could not get start event to fire in demo application. https://wiki.freepascal.org/Daemons_and_Services https://github.com/arminlinder/Lazarus-FPC-Wiki-Code- Samples/zipball/master/ I modified the code below and now it works, so looks like the demo needs a small fix to the Format function call (seems it wants 2 parameters string and number )? See DaemonUnit1.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TDaemon1.DataModuleStart(Sender: TCustomDaemon; var OK: Boolean);begin  LogToFile('STARTED');  {-m.c.  LogToFile(Format('Daemon %s received start signal, PID:%d', [GetProcessID]));  // Create a suspended worker thread - see DaemonWorkerThread unit  FDaemonWorkerThread := TDaemonWorkerThread.Create;  // Parametrize it  FDaemonWorkerThread.FreeOnTerminate := False;  // Start the worker  FDaemonWorkerThread.Start;  }  OK := True;end;   Log: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 12:54:43 Log created12:54:43 Daemon received stop signal12:54:43 Daemon stopped12:55:08 Daemon installing12:55:08 Daemon installed12:55:39 STARTED ---------------------------------------------------------------------- TRon · 2023-02-02 13:13 Quote from: Michael Collier on February 02, 2023, 02:05:51 pmhttps://wiki.freepascal.org/Daemons_and_Services I modified the code below and now it works, so looks like the demo needs a small fix to the Format function call (seems it wants 2 parameters string and number )? copy-paste error ? this is what I read/see: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TDaemon1.DataModuleStart(Sender: TCustomDaemon; var OK: Boolean);begin  LogToFile(Format('Daemon received start signal, PID:%d', [GetProcessID]));  // Create a suspended worker thread - see DaemonWorkerThread unit  FDaemonWorkerThread := TDaemonWorkerThread.Create;  // Parametrize it  FDaemonWorkerThread.FreeOnTerminate := False;  // Start the worker  FDaemonWorkerThread.Start;  OK := True;end; Thus the format only has one used format parameter (did you added the %s yourself, perhaps copied from the second example that does use two format parameter strings ?)  But yes, that call to format as you have shown will fail because it is missing a string for first parameter (you only supplied one integer with the call to GetProcessID() ) ---------------------------------------------------------------------- Michael Collier · 2023-02-02 13:31 Ahh I think I know what the problem is , I'm using the code from the zip download that contains the error https://github.com/arminlinder/Lazarus-FPC-Wiki-Code- Samples/zipball/master/ The code in the wiki is correct, but download demo project is wrong? ---------------------------------------------------------------------- TRon · 2023-02-02 13:35 Quote from: Michael Collier on February 02, 2023, 02:31:32 pmThe code in the wiki is correct, but download demo project is wrong? Indeed i was copying the wiki entry. Because I did not trusted it I downloaded the zipfile and indeed there the error is present. You can easily solve that with for example: Code: [Select] LogToFile(Format('Daemon %s received start signal, PID:%d', ['the_name_of_your_daemon', GetProcessID])); or replace it as per wiki entry. At least it keeps you/us alert ---------------------------------------------------------------------- Michael Collier · 2023-02-02 19:15 I added an issue in github https://github.com/arminlinder/Lazarus-FPC-Wiki-Code-Samples/issues/2 Hopefully the demo will be fixed, it's working great for me.. ---------------------------------------------------------------------- ArminLinder · 2023-05-12 07:50 Corrected! Thanks very much for your contribution. Armin.