[Lazarus] Making a Linux systemd service, how does one handle the shutdown?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Making a Linux systemd service, how does one handle the shutdown?

Free Pascal - Lazarus mailing list
I have read that a systemd service on Linux will be taken down by the
service manager using kill -TERM, i.e. the application is given a
chance for a clean shutdown.

So my question is:
How/where do I implement a handler for the terminate message in a
FreePascal console application (no GUI or form available)?

I have never done anything similar to this but I think that this might
be a way to solve my problem of porting a Windows TService application
to Linux by changing the framework from the Delphi TService to a
simple program...


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Making a Linux systemd service, how does one handle the shutdown?

Free Pascal - Lazarus mailing list


On Sun, 21 Jun 2020, Bo Berglund via lazarus wrote:

> I have read that a systemd service on Linux will be taken down by the
> service manager using kill -TERM, i.e. the application is given a
> chance for a clean shutdown.
>
> So my question is:
> How/where do I implement a handler for the terminate message in a
> FreePascal console application (no GUI or form available)?

https://www.freepascal.org/docs-html/current/rtl/sysutils/hooksignal.html

or

https://www.freepascal.org/docs-html/current/rtl/baseunix/fpsigaction.html
You should install handlers for SIGQUIT/SIGTERM/SIGINT

The hooksignal internally uses fpsigaction, by the way.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus