Created
September 6, 2014 18:03
-
-
Save azeitler/320646d9771785d0a4f1 to your computer and use it in GitHub Desktop.
OS X Jenkins Shell Wrapper
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/sh | |
DESC="Jenkins CI Server" | |
NAME=jenkins | |
PIDFILE=$HOME/$NAME.pid | |
LOGFILE=$HOME/Library/Logs/dopanic.$NAME.log | |
d_start() { | |
(nohup java -XX:PermSize=512M -XX:MaxPermSize=2048M -Xmn128M -Xms1024M -Xmx2048M -jar /usr/local/opt/jenkins/libexec/jenkins.war > $LOGFILE 2>&1) & | |
PID=$! | |
echo "$PID" > $PIDFILE | |
} | |
d_stop() { | |
if [ -e $PIDFILE ]; then | |
PID=$(cat $PIDFILE) | |
kill $PID | |
rm $PIDFILE | |
echo "Stopped Process ID: $PID." | |
else | |
echo "No PID file. Process not running." | |
fi | |
if [ -e $LOGFILE ]; then | |
rm -rf $LOGFILE.previous | |
cp $LOGFILE $LOGFILE.previous | |
rm $LOGFILE | |
fi | |
} | |
case $1 in | |
start) | |
echo "Starting $DESC: $NAME" | |
d_start | |
echo "Started with Process ID: $PID." | |
;; | |
stop) | |
echo "Stopping $DESC: $NAME" | |
d_stop | |
;; | |
status) | |
echo "Status of $DESC: $NAME" | |
if [ -e $PIDFILE ] | |
then echo "$PIDFILE exists... service running." | |
fi | |
;; | |
log) | |
echo "Log of $DESC: $NAME" | |
if [ -e $LOGFILE ] | |
then cat $LOGFILE | |
fi | |
;; | |
restart) | |
echo "Restarting $DESC: $NAME" | |
d_stop | |
sleep 1 | |
d_start | |
echo "Restarted." | |
;; | |
*) | |
echo "usage: $NAME {start|stop|restart|status|log}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment