Skip to content

Instantly share code, notes, and snippets.

@winsonwq
Last active October 12, 2020 20:15
Show Gist options
  • Save winsonwq/7197400 to your computer and use it in GitHub Desktop.
Save winsonwq/7197400 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
@nonongodup
Copy link

where we should we include this file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment