Creating a service handled by systemd #
This is only a sort of reminder on how to install Epeios related daemons on a Debian system. It’s not a comprehensive documentation about sytemd.
Unit file #
To create a service for systemd, you have to create a .service
suffixed file in /etc/systemd/system/
which looks like:
[Unit]
Description=<description>
After=network.target
[Service]
ExecStart=<command>
Restart=always
[Install]
WantedBy=multi-user.target
where <description>
is a string describing the service, and <command>
the command with its arguments to launch the daemon. If <command>
contains %
symbols, they must be doubled!
Example:
[Unit]
Description=Demonstration of the XDHTML technology as web application
After=network.target
[Service]
ExecStart=/home/csimon/services/dmnzq /home/csimon/services/dmnzq.xprj
Restart=always
[Install]
WantedBy=multi-user.target
Registering #
In order to the service to start at boot, you must somehow registering it with following command:
systemctl enable /etc/systemd/system/<service>.service
where <service>
is the service name.
Example:
systemctl enable /etc/systemd/system/xdhdq.service
You must also do this after the modification of the unit file!
This does not start the service ; see below for this.
Starting/stopping #
To start a service, use following command:
systemctl start <service>
where <service>
is the service name.
Example:
systemctl start xdhdq
To stop, type stop
instead of start
.
It works also with the System V service
command instead of
systemctl
.
Unregistering #
In order to remove the service from the boot sequence, you must somehow unregistering it with following command:
systemctl disable /etc/systemd/system/<service>.service
where <service>
is the service name.
Example:
systemctl disable /etc/systemd/system/xdhdq.service
This does not stop the service ; see above for this.
Sending a SMS when the service is (re)started #
This can be done with ExecStartPost
.
Example:
[Unit]
Description=Demonstration of the XDHTML technology as web application
After=network.target
[Service]
ExecStart=/home/csimon/services/dmnzq /home/csimon/services/dmnzq.xprj
ExecStartPost=/usr/bin/wget -qO- "https://smsapi.free-mobile.fr/sendmsg?user=<user>&pass=<pass>&msg=<msg>"
Restart=always
[Install]
WantedBy=multi-user.target
If
<msg>
contains%
symbols (if it is URL encoded), they must be doubled!