-
-
Save kohenkatz/e505eeb34ef982d99636 to your computer and use it in GitHub Desktop.
How to run a FastCGI process as a service under Systemd, based on http://redmine.lighttpd.net/projects/spawn-fcgi/wiki/Systemd/2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ "${LISTEN_PID}" != $$ ]; then | |
echo >&2 "file descriptors not for us, pid not matching: '${LISTEN_PID}' != '$$'" | |
exit 255 | |
fi | |
if [ "${LISTEN_FDS}" != "1" ]; then | |
echo >&2 "Requires exactly one socket passed to fastcgi, got: '${LISTEN_FDS:-0}'" | |
exit 255 | |
fi | |
unset LISTEN_FDS | |
# move socket from 3 to 0 | |
exec 0<&3 | |
exec 3<&- | |
# spawn fastcgi backend | |
exec "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=WebApp service | |
After=network.target postgresql.service mysql.service | |
Wants=postgresql.service mysql.service | |
[Service] | |
User=webappuser | |
Group=webappgroup | |
StandardOutput=null | |
StandardError=syslog | |
ExecStart=/usr/local/sbin/systemd-spawn-fcgi.sh /home/webappuser/webapp/runfcgi | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=WebApp Listen Socket | |
[Socket] | |
SocketUser=www-data | |
SocketGroup=www-data | |
SocketMode=0600 | |
ListenStream=/run/webapp.sock | |
[Install] | |
WantedBy=sockets.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment