Skip to content

Instantly share code, notes, and snippets.

@ryross
Last active April 12, 2016 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryross/5b7a2703020946260440 to your computer and use it in GitHub Desktop.
Save ryross/5b7a2703020946260440 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Script for starting phantomjs.
#
. /etc/rc.d/init.d/functions
USER="phantomjs"
DAEMON="/usr/local/phantomjs/bin/phantomjs --webdriver=4445 --ignore-ssl-errors=true "
LOG_FILE="/var/log/phantomjs/main.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
@victor-crasnea
Copy link

replace line no 11
DAEMON="/usr/local/phantomjs/bin/phantomjs --webdriver=4445 --ignore-ssl-errors=true " (you have a white space)
with
DAEMON="/usr/local/phantomjs/bin/phantomjs --webdriver=4445 --ignore-ssl-errors=true".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment