Forked from alexnederlof/selenium-start-stop.sh
Last active
December 1, 2016 05:14
-
-
Save philstark/f0b23d464d4292459926c041012db3e5 to your computer and use it in GitHub Desktop.
Selenium start-stop script
This file contains 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 | |
# Note that this script requires you to have | |
# an X window running on Display :90 | |
# This can be done by running: /usr/bin/Xvfb :90 -ac -screen 0 1024x768x8 & | |
# | |
# You can save this script as /etc/init.d/selenium to start and stop selenium | |
PORT=4444 | |
DESC="Selenium server" | |
RUN_AS=selenium | |
JAVA_BIN=/usr/bin/java | |
SELENIUM_DIR=/etc/selenium | |
PID_FILE="/var/run/selenium.pid" | |
JAR_FILE="/var/lib/selenium/selenium-server.jar" | |
LOG_FILE="/var/log/selenium/selenium.log" | |
CHROME_DRIVER="/usr/local/share/chromedriver" | |
DAEMON_OPTS=" -jar $JAR_FILE -Dwebdriver.chrome.driver=$CHROME_DRIVER -Djava.security.egd=file:/dev/./urandom -log $LOG_FILE -port $PORT" | |
NAME=selenium | |
export DISPLAY=:90 | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
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." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|force-reload}" >&2 | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment