Last active
October 15, 2023 14:45
-
-
Save demofly/6e0cdf3d3c10d74910fa to your computer and use it in GitHub Desktop.
Phantomjs startup script for Centos
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/sh | |
# | |
# chkconfig: - 35 99 99 | |
# description: phantomjs zombo launchery | |
# | |
### BEGIN INIT INFO | |
# Provides: phantomjs | |
# Required-Start: $local_fs $network | |
# Required-Stop: $local_fs $network | |
# Default-Start: | |
# Default-Stop: 0 1 2 3 4 5 6 | |
# Short-Description: Start and stop Zabbix server | |
# Description: Zabbix server | |
### END INIT INFO | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
if [ -x /usr/bin/phantomjs ]; then | |
exec=phantomjs | |
else | |
exit 5 | |
fi | |
if [ -f /etc/sysconfig/phantomjs ]; then | |
. /etc/sysconfig/phantomjs | |
fi | |
OPTIONS="--webdriver=127.0.0.1:8910" | |
if [ -f /etc/sysconfig/phantomjs ];then | |
. /etc/sysconfig/phantomjs | |
fi | |
# Check that networking is up. | |
. /etc/sysconfig/network | |
if [ "$NETWORKING" = "no" ] | |
then | |
exit 0 | |
fi | |
RETVAL=0 | |
pidfile=${PIDFILE-/var/run/phantomjs/phantomjs.pid} | |
lockfile=${LOCKFILE-/var/lock/subsys/phantomjs} | |
USER="nginx" | |
DAEMON="/usr/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs ${OPTIONS}" | |
LOG_FILE="/var/log/phantomjs/phantomjs.log" | |
do_start() | |
{ | |
echo -n $"Starting PhantomJS : " | |
runuser -l "$USER" -c "$DAEMON >> $LOG_FILE &" && echo_success || echo_failure | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] | |
} | |
do_stop() | |
{ | |
echo -n $"Stopping PhantomJS : " | |
pid=`ps -aefw | grep "$DAEMON" | grep -v " grep " | awk '{print $2}'` | |
kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] | |
} | |
case "$1" in | |
start) | |
do_start | |
;; | |
stop) | |
do_stop | |
;; | |
restart) | |
do_stop | |
do_start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
RETVAL=1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment