How to convert my program into a service?
Tom H
tomh0665 at gmail.com
Thu Apr 1 09:30:36 UTC 2021
On Tue, Mar 30, 2021 at 10:06 AM Bo Berglund <bo.berglund at gmail.com>
wrote:
>
> I have ported a Windows service application originally created
> using Borland Delphi using its template TService. Right now this
> ported version is a simple command line program written with Free
> Pascal and it works as intended if started manually from a
> terminal.
>
> Now I want to convert it into a Linux service under systemd, but I
> am confused by reading what I find when googling...
>
> Is there a authoritative howto document which describes how this
> should be done including where to put which files?
>
> I want the service to be run under a specific user account so that
> the data files it produces will be accessible by regular users
> belonging to the same group as the service user.
>
> The application is a control server for external equipment and it
> can be interacted with through a proprietary TCP/IP socket
> interface. It uses sockets and serial ports for its operation. (I
> don't know if this is important but I add it here just in case).
>
> If additional info is needed I can provide it.
Create "/etc/systemd/system/your_daemon.service" (most basically!) with
[Unit]
Description=your_daemon
After=
Requires=
[Service]
Type=simple|forking ## there are other types ...
PIDFile= ## if Type=forking
ExecStart=/usr/local/bin/your_daemon [options]
User=your_daemon_user
[Install]
WantedBy=multi-user.target
If you need a file or directory created under "/run", create a file
under "/etc/tmpfiles.d" for it.
More information about the ubuntu-users
mailing list