Last active
January 19, 2018 11:57
-
-
Save ihor/3827257 to your computer and use it in GitHub Desktop.
/etc/init.d/php-fpm script for Homebrew installed PHP-FPM
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 | |
DAEMON=/usr/local/sbin/php-fpm | |
OPTS='--fpm-config /usr/local/etc/php5/fpm/php-fpm.conf' | |
NAME='php-fpm' | |
DESC=php-fpm | |
test -x $DAEMON || exit 0 | |
set -e | |
test_config() | |
{ | |
FPM_ERROR=$($DAEMON $OPTS -t 2>&1 | grep "\[ERROR\]") | |
if [ -n "${FPM_ERROR}" ]; then | |
echo "Please fix your configuration file..." | |
$DAEMON $OPTS -t 2>&1 | grep "\[ERROR\]" | |
return 1 | |
fi | |
return 0 | |
} | |
start() | |
{ | |
$DAEMON $OPTS | |
return | |
} | |
stop() | |
{ | |
kill `cat /usr/local/var/run/php-fpm.pid` | |
return | |
} | |
reload() | |
{ | |
kill -USR2 `cat /usr/local/var/run/php-fpm.pid` | |
return | |
} | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start | |
echo "started." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
stop | |
echo "stopped." | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
stop | |
sleep 1 | |
start | |
echo "restarted." | |
;; | |
reload) | |
echo -n "Reloading $DESC configuration: " | |
if test_config; then | |
reload | |
echo "reloaded." | |
else | |
exit $? | |
fi | |
;; | |
configtest|testconfig) | |
echo -n "Testing $DESC configuration: " | |
if test_config; then | |
echo "config is ok." | |
else | |
exit $? | |
fi | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|reload|force-reload|configtest}" >&2 | |
exit 1 | |
;; | |
esac | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment