Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 73 lines (63 sloc) 2.169 kB
#!/usr/bin/env bash
#
# Usage: grid-hub {start|stop}
#
source $(dirname $0)/util
EXPECTED_ARGS=1
E_BADARGS=65
DO_showUsage() {
echo "Usage: $(basename $0) {start|stop}"
exit $E_BADARGS
}
if [ $# -ne $EXPECTED_ARGS ]; then
DO_showUsage
fi
################################################################################
WEBDRIVER_SERVER_JAR=/opt/selenium-server-standalone.jar
# API default is 4444, so for testing we'll use 3333
WEBDRIVER_HUB_PARAMS="-role hub -port 3333"
WEBDRIVER_HUB_PIDFILE="/tmp/webdriver_hub.pid"
if [ ! -f $WEBDRIVER_SERVER_JAR ]; then
echo "You must place the Selenium-WebDriver standalone JAR file at ${WEBDRIVER_SERVER_JAR} before proceeding."
exit 1
fi
case "$1" in
start)
echo "Starting Selenium-WebDriver Grid2 hub..."
if [ -f $WEBDRIVER_HUB_PIDFILE ]; then
echo "${FAIL_MSG} Selenium-WebDriver Grid2 hub already running with PID $(cat $WEBDRIVER_HUB_PIDFILE). Run 'grid-hub stop' or 'grid-hub restart'."
exit 1
else
START_HUB_CMD="java -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_HUB_PARAMS}"
$START_HUB_CMD &
PID=$!
echo $PID > "${WEBDRIVER_HUB_PIDFILE}"
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub started successfully."
fi
;;
stop)
echo "Stopping Selenium-WebDriver Grid2 hub..."
if [ -f $WEBDRIVER_HUB_PIDFILE ]; then
PID=$(cat $WEBDRIVER_HUB_PIDFILE)
kill $PID
rm $WEBDRIVER_HUB_PIDFILE
sleep 1
if [[ $(ps -A | egrep "^${PID}") ]]; then
echo "${FAIL_MSG} Tried to kill the hub with PID ${PID}, but was unsuccessful. You need to kill it with something stronger, like 'kill -9'"
exit 1
else
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub stopped successfully."
exit 0
fi
else
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub has already been stopped."
exit 0
fi
;;
restart)
$0 stop
$0 start
;;
*)
DO_showUsage
esac
Jump to Line
Something went wrong with that request. Please try again.