C
C
chelkaz2017-03-11 19:03:47
linux
chelkaz, 2017-03-11 19:03:47

How to add a command to systemd?

I have service centrifugo.service

[Unit]
Description=Centrifugo real-time messaging server
Documentation=https://github.com/centrifugal/centrifugo
# start once the network and logging subsystems available
After=network.target syslog.target

[Service]
User=centrifugo
Group=centrifugo
LimitNOFILE=65536
Environment="CONFIG=/etc/centrifugo/config.json"
EnvironmentFile=/etc/default/centrifugo
ExecStartPre=/usr/bin/centrifugo checkconfig -c $CONFIG
ExecStart=/usr/bin/centrifugo -c $CONFIG $CENTRIFUGO_OPTS
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -SIGTERM $MAINPID
TimeoutStopSec=10
KillMode=control-group
RestartSec=1
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=centrifugo

[Install]
WantedBy=multi-user.target
Alias=centrifugo.service

For my work, I need it to be run with flags all the time:
Here is the command:
# centrifugo -w --config="/etc/centrifugo/config.json"
Created a custom cfugo.service
And wrote it there:
[Unit]
Description=Centrifugo worker

[Service]
Restart=on-failure
ExecStart=/usr/bin/centrifugo -w --config="/etc/centrifugo/config.json"

[Install]
WantedBy=multi-user.target

It runs without errors, but it doesn't work the way I run it just from the console:
And if just from the console like centrifugo -w --config="/etc/centrifugo/config.json
Then it starts working correctly...
What's wrong am I doing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2017-03-12
@MechanID

To make the service start and run in the background - add
Type=forking to [Service]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question