At the end what I did was:
- make the daemon (easy, just see the examples)
- create a systemd config file and make sure to have:
[Unit]
Description=TT daemon
[Service]
Type=forking
WorkingDirectory=/home/user_tt/.tt_daemon
ExecStart=/usr/local/bin/tt_daemon -r -b
User=user_tt
Group=users
- the option -r in the ExecStart line tells the daemon to run
- the option -b in the ExecStart line tells the daemon created with fpc to daemonize itself = fork and become background process
- the Type=forking is designed to deal with processes capable of daemonizing
in alternative
[Unit]
Description=TT daemon
[Service]
Type=simple
WorkingDirectory=/home/user_tt/.tt_daemon
ExecStart=/usr/local/bin/tt_daemon -r
User=user_tt
Group=users
- skip the option -b in the ExecStart so that the daemon will start and not daemonize itself (it will keep runnig until stopped from outside or it crashes)
- in this case I have to use Type=simple (is the default) which is designed to deal with processes that do not daemonize, and systemd will go ahead with other services without being locked by my process.