Last active
October 12, 2020 20:15
-
-
Save winsonwq/7197400 to your computer and use it in GitHub Desktop.
selenium webdriver as background
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 | |
# 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
where we should we include this file?