I'm having trouble using ExecStartPost
in a systemd service. Even with the following simple command:
ExecStartPost=/bin/sh -c "exit 0"
… when I start the service, I get a "time out" error:
start-post operation timed out. Stopping.
Here is my full service definition. mbtileserver
is a blocking program, not a daemon.
[Unit]
Description=mbtileserver daemon
After=network.target
[Service]
Type=simple
PIDFile=/home/crp/var/run/mbtileserver.pid
User=crp
Group=crp
WorkingDirectory=/home/crp
ExecStart=/home/crp/go/bin/mbtileserver -d /home/crp/tiles/ -p 8080 -s "eGJ0NwI9_OyxHEFvBcU-9zR6O89z_S0RNfIOSP3utSU"
ExecStartPost=/bin/sh -c "exit 0"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
How do I create an ExecStartPost
that doesn't time out?
Best Answer
I eventually discovered that the problem was that
PIDFile
didn't exist. This doesn't appear to be documented, but you need a validPIDFile
in order to useExecStartPost
(possibly noPIDFile
would work, but an missing file definitely doesn't work).Ironically, I was going to use
ExecStartPost
to create the pid file, but wanted to try it with something simple (originally had anecho
) first.Changing
ExecStartPost
to the following made the service work: