Created
March 28, 2015 09:09
-
-
Save stbuehler/439a9849747279a1f0a9 to your computer and use it in GitHub Desktop.
systemd to FastCGI socket passing compatibility script
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 "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do you need separate script for it?
Systemd can pass socket as stdin (0), not 3.
See "StandardInput=socket".
Following config works for me: