Skip to content

Instantly share code, notes, and snippets.

@vtraida
Forked from winsonwq/selenium-server.sh
Created October 23, 2019 14:35
Show Gist options
  • Save vtraida/357c9b30bf2bbf5b03c9bcf63b00f5e8 to your computer and use it in GitHub Desktop.
Save vtraida/357c9b30bf2bbf5b03c9bcf63b00f5e8 to your computer and use it in GitHub Desktop.
selenium webdriver as background
#!/bin/bash
# Start the service selenium-server
start() {
echo "Starting selenium-server server."
export DISPLAY=:0
java -jar /Users/tw/Projects/test/selenium-server-standalone-2.35.0.jar -role hub &>/dev/null &
PID=$!
### Create the lock file ###
echo $PID > /var/run/selenium-server.pid
echo $"selenium-server server startup $PID."
}
# Restart the service selenium-server
stop() {
echo "Stopping selenium-server server."
cat /var/run/selenium-server.pid | xargs kill -15
### Now, delete the PID file ###
rm -f /var/run/selenium-server.pid
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
if [ -f /var/run/selenium-server.pid ]; then
PID=`cat /var/run/selenium-server.pid`
if [ $PID -gt 0 ]; then
echo "Selenium server is running with process id $PID."
fi
else
echo 'Selenium server is not running.'
fi
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment