Forked from zEvg/Selenium Grid init.d script for CentOS 5.5
Created
September 27, 2012 17:13
-
-
Save jujhars13/3795204 to your computer and use it in GitHub Desktop.
inid.d 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/bash | |
# /etc/init.d/selenium-grid | |
# centos-compatible selenium-grid startup script. | |
# Eugene Zakharchenko <z.evgeniy[at]gmail.com> | |
### BEGIN INIT INFO | |
# Provides: selenium-grid | |
# Required-Start: $remote_fs $syslog $network | |
# Required-Stop: $remote_fs $syslog $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start selenium at boot time | |
# Description: Controls selenium grid. | |
### END INIT INFO | |
# Source function library. | |
. /etc/init.d/functions | |
# Place for pid file | |
SELENIUM_PID=/var/run/selenium-grid.pid | |
# Create selenium user before or change it | |
SELENIUM_USER=selenium | |
# Log dile | |
SELENIUM_LOG_FILE=/var/log/selenium/selenium.log | |
# Java interpreter | |
JAVA_CMD=/usr/bin/java | |
# Version of Selenium grid you're using | |
SELENIUM_GRID_VERSION=1.0.8 | |
# Selenium Grid home directory | |
SELENIUM_GRID_HOME=/usr/local/selenium-grid | |
# Class path for SG | |
SELENIUM_GRID_HOME_CLASSPATH="$SELENIUM_GRID_HOME:$SELENIUM_GRID_HOME/lib/selenium-grid-hub-standalone-$SELENIUM_GRID_VERSION.jar" | |
# Options for running SG | |
PARAMS="-classpath $SELENIUM_GRID_HOME_CLASSPATH com.thoughtworks.selenium.grid.hub.HubServer" | |
case "$1" in | |
start) | |
echo -n "Starting Selenium Grid ..." | |
# ensure that we have a dir for the logs | |
if [ ! -f $SELENIUM_LOG_FILE ]; then | |
mkdir $(dirname $SELENIUM_LOG_FILE) > /dev/null 2>$1 | |
chown $SELENIUM_USER:$SELENIUM_USER $(dirname $SELENIUM_LOG_FILE) > /dev/null 2>$1 | |
fi | |
# retrieving pid of the paretn process | |
/bin/su -l "$SELENIUM_USER" --shel=/bin/bash -c "$JAVA_CMD $PARAMS 2> $SELENIUM_LOG_FILE &" | |
echo $(ps hww -u "$SELENIUM_USER" -o pid,cmd | grep -v bash | cut -d ' ' -f 1) > "$SELENIUM_PID" | |
if [ $? == "0" ]; then | |
success | |
else | |
failure | |
fi | |
echo | |
echo "Log file: $SELENIUM_LOG_FILE" | |
;; | |
status) | |
status -p "$SELENIUM_PID" selenium | |
;; | |
stop) | |
echo -n "Killing Selenium Grid ..." | |
killproc -p "$SELENIUM_PID" selenium | |
echo | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|restart}" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment