Skip to content

Instantly share code, notes, and snippets.

@emerleite
Created April 30, 2010 18:15
Show Gist options
  • Save emerleite/385572 to your computer and use it in GitHub Desktop.
Save emerleite/385572 to your computer and use it in GitHub Desktop.
#!/bin/bash
### BEGIN INIT INFO
# Provides: Start Selenium server
# Author: Emerson Macedo - http://github.com/emerleite - http://codificando.com
# Description: Manage selenium server start and stop
### END INIT INFO
NAME="selenium"
PIDFILE="./selenium.pid"
LOGFILE="./selenium.log"
start_app() {
if [ -f $PIDFILE ]
then
echo "$NAME already started"
exit 1
fi
java -jar selenium-server.jar > $LOGFILE & echo $! > $PIDFILE
}
stop_app() {
if [ ! -f $PIDFILE ]
then
echo "$NAME is not started"
exit 1
fi
kill -9 `cat $PIDFILE`
rm -f $PIDFILE
}
case "$1" in
start)
echo "Startando $NAME "
start_app
echo "$NAME started"
;;
stop)
echo "Stopping $NAME"
stop_app
echo "$NAME stopped"
;;
restart|force-reload)
echo -n "Restarting $NAME"
stop_app
sleep 2
start_command
echo "$NAME restarted"
;;
*)
echo "Usage: $NAME.sh {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment