1

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?

1 Answers1

2

I eventually discovered that the problem was that PIDFile didn't exist. This doesn't appear to be documented, but you need a valid PIDFile in order to use ExecStartPost (possibly no PIDFile 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 an echo) first.

Changing ExecStartPost to the following made the service work:

ExecStartPost=/bin/sh -c "pgrep -o mbtileserver > /home/crp/var/run/mbtileserver.pid"