I used the following config to start beanstalkd
process
[Service]
ExecStart=/usr/local/bin/beanstalkd
ExecStartPost=pgrep beanstalkd > /var/run/beanstalkd.pid
The last line is supposed to generate a pidfile after the process in launched, but the file is not created. why ?
Or is there another way to force pidfile creation in systemd
?
Best Answer
systemd does not require a pidfile for a Type=simple service. It will manage the daemon in the foreground.
systemctl status SERVICE_NAME
will show the pid of the main process (and of any other processes in the cgroup).For completeness, your ExecStartPost line did not work because systemd does not use a shell to execute commands and does not perform $PATH lookup, so you would have to use
ExecStartPost=/bin/sh -c "..."
, but as I said, the line is unnecessary.