-
-
Save shchavla/9756381 to your computer and use it in GitHub Desktop.
Revisions
-
marten-cz created this gist
Nov 6, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ #!/bin/bash DESC="Selenium Grid Server" RUN_AS="selenium" JAVA_BIN="/usr/bin/java" SELENIUM_DIR="/opt/selenium" PID_FILE="$SELENIUM_DIR/selenium-grid.pid" JAR_FILE="$SELENIUM_DIR/selenium-server.jar" LOG_DIR="/var/log/selenium" LOG_FILE="${LOG_DIR}/selenium-grid.log" USER="selenium" GROUP="selenium" MAX_MEMORY="-Xmx256m" STACK_SIZE="-Xss8m" DAEMON_OPTS=" $MAX_MEMORY $STACK_SIZE -jar $JAR_FILE -role hub -log $LOG_FILE" NAME="selenium" if [ "$1" != status ]; then if [ ! -d ${LOG_DIR} ]; then mkdir --mode 750 --parents ${LOG_DIR} chown ${USER}:${GROUP} ${LOG_DIR} fi fi # TODO: Put together /etc/init.d/xvfb # export DISPLAY=:99.0 . /lib/lsb/init-functions case "$1" in start) echo -n "Starting $DESC: " if start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS ; then log_end_msg 0 else log_end_msg 1 fi ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --pidfile $PID_FILE echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --pidfile $PID_FILE sleep 1 start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS echo "$NAME." ;; status) status_of_proc -p "$PID_FILE" "$DAEMON" "selenium" && exit 0 || exit $? ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,84 @@ #!/bin/bash DESC="Selenium Grid Server" RUN_AS="selenium" JAVA_BIN="/usr/bin/java" PORT=5560 HUBURL="http://127.0.0.1:4444/grid/register" SELENIUM_DIR="/opt/selenium" PID_FILE="$SELENIUM_DIR/selenium-node.pid" JAR_FILE="$SELENIUM_DIR/selenium-server.jar" LOG_DIR="/var/log/selenium" LOG_FILE="${LOG_DIR}/selenium-grid.log" USER="selenium" GROUP="selenium" MAX_MEMORY="-Xmx256m" STACK_SIZE="-Xss8m" BROWSER="browserName=firefox,version=3.5,firefox_binary=/usr/bin/iceweasel,maxInstances=5,platform=LINUX" DAEMON_OPTS=" -client $MAX_MEMORY $STACK_SIZE -jar $JAR_FILE -browser ${BROWSER} -role node -port ${PORT} -hub ${HUBURL} -log $LOG_FILE" DISPLAY_PORT=501 XVFB="/usr/bin/Xvfb" XVFB_OPTS=" :${DISPLAY_PORT} -screen 0 1024x768x24" XVFB_PID_FILE="$SELENIUM_DIR/xvfb-node.pid" NAME="Selenium Node" if [ "$1" != status ]; then if [ ! -d ${LOG_DIR} ]; then mkdir --mode 750 --parents ${LOG_DIR} chown ${USER}:${GROUP} ${LOG_DIR} fi fi . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Starting ${DESC}: " "Xvfb" if start-stop-daemon -c $RUN_AS --start --background --pidfile $XVFB_PID_FILE --make-pidfile --exec $XVFB -- $XVFB_OPTS ; then log_end_msg 0 else log_end_msg 1 exit 1 fi export DISPLAY=:${DISPLAY_PORT}.0 log_daemon_msg "Starting ${DESC}: " $NAME if start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS ; then log_end_msg 0 else log_end_msg 1 fi ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --pidfile $XVFB_PID_FILE start-stop-daemon --stop --pidfile $PID_FILE echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --pidfile $PID_FILE sleep 1 start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS echo "$NAME." ;; status) status_of_proc -p "$XVFB_PID_FILE" "$DAEMON" "Xvfb" && status_of_proc -p "$PID_FILE" "$DAEMON" "Selenium node" && exit 0 || exit $? ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac