Skip to content

Instantly share code, notes, and snippets.

@techwhizbang
Created October 28, 2011 17:34
Show Gist options
  • Save techwhizbang/1322837 to your computer and use it in GitHub Desktop.
Save techwhizbang/1322837 to your computer and use it in GitHub Desktop.
Selenium Grid service script
#!/bin/bash
case "${1:-''}" in
'start')
if test -f /tmp/selenium-grid.pid
then
echo "Selenium Grid is already running."
else
java -jar /home/bkr/selenium/selenium-server-standalone-2.9.0.jar -port 5555 -role hub > /var/log/selenium/selenium-grid.log 2> /var/log/selenium/selenium-grid-error.log & echo $! > /tmp/selenium-grid.pid
echo "Starting Selenium Grid..."
error=$?
if test $error -gt 0
then
echo "${bon}Error $error! Couldn't start Selenium Grid!${boff}"
fi
fi
;;
'stop')
if test -f /tmp/selenium-grid.pid
then
echo "Stopping Selenium Grid..."
PID=`cat /tmp/selenium-grid.pid`
kill -3 $PID
if kill -9 $PID ;
then
sleep 2
test -f /tmp/selenium-grid.pid && rm -f /tmp/selenium-grid.pid
else
echo "Selenium Grid could not be stopped..."
fi
else
echo "Selenium Grid is not running."
fi
;;
'restart')
if test -f /tmp/selenium-grid.pid
then
kill -HUP `cat /tmp/selenium-grid.pid`
test -f /tmp/selenium-grid.pid && rm -f /tmp/selenium-grid.pid
sleep 1
java -jar /home/bkr/selenium/selenium-server-standalone-2.9.0.jar -port 5555 -role hub > /var/log/selenium/selenium-grid.log 2> /var/log/selenium/selenium-grid-error.log & echo $! > /tmp/selenium-grid.pid
echo "Reload Selenium Grid..."
else
echo "Selenium Grid isn't running..."
fi
;;
*) # no parameter specified
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment