arved
arved

Reputation: 4576

systemd: How to use ExecStopPre in service files

Before my daemon is stopped I need to do call another program.

My first try was to use ExecStopPre similar to ExecStartPre but according to https://bugs.freedesktop.org/show_bug.cgi?id=73177 this is not supported and I should use "multiple ExecStop".

Anyone got an example for this? How should i kill the daemon from ExecStop?

Upvotes: 11

Views: 20278

Answers (1)

vortarian
vortarian

Reputation: 166

You put multiple lines with ExecStop (from a node.js service): e.g.

[Service]
ExecStartPre=/usr/local/bin/npm run build
ExecStartPre=-/bin/rm local.sock
ExecStart=/usr/local/bin/npm --parseable start 
ExecStop=/usr/local/bin/npm --parseable stop
ExecStop=-/bin/rm local.sock
RestartSec=300
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs
User=nobody
Group=nobody
Environment=NODE_ENV=dev
Environment=PORT=3000
WorkingDirectory=/var/www/nodejs/quaff
UMask=007

Upvotes: 15

Related Questions