I have written some simple daemon and I want my system to automatically start it on boot. My daemon needs bluetooth daemon to be started and UNIX socket for outputting data. What is a bit different from what can be read in most manuals and tutorials about systemd is that from daemon point of view I want systemd to create socket for writing, not listening. When I start service and socket manually everything works, however after executing systemctl enable foo.service
my daemon is not started after reboot. Based on man systemd.unit
, man systemd.target
and some googling I have created 3 unit files.
Due to the fact that there seems to be at least few ways in which dependencies can be described for systemd I don't know what is wrong, why my service is not automatically started after reboot. Should I create foo.target file or is it unnecessary in such simple scenario? I am also not sure if WantedBy
in foo.socket should be set to foo.target or more maybe to sockets.target.
Here is code snippet of my 3 unit files below. I would really appreciate if someone could take a look and give me some tips.
############ foo.service file #############################################
[Unit]
Description=Foo Service
Requires=foo.socket
[Service]
Type=simple
ExecStart=/path/to/start
[Install]
WantedBy=foo.target
###########################################################################
############ foo.socket file ##############################################
[Unit]
Description=Foo socket for write, not for listen
[Socket]
ListenDatagram=/run/foo/foo.sk
[Install]
WantedBy=foo.target
###########################################################################
############ foo.target file ##############################################
[Unit]
Description=Foo target
Requires=bluetooth.target
###########################################################################