Skip to content

Instantly share code, notes, and snippets.

@Ribesg
Created March 12, 2014 18:16
Show Gist options
  • Save Ribesg/9512947 to your computer and use it in GitHub Desktop.
Save Ribesg/9512947 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd /home/blob
BLOB_CMD="java -jar /home/blob/Blob.jar"
BLOB_PID=`ps -ef | grep "$BLOB_CMD" | grep -v grep | awk '{print $2}'`
if [[ $BLOB_PID != *[!0-9]* ]]; then
echo "Blob is running, killing Blob"
kill -9 $BLOB_PID
echo "Waiting for Blob to stop..."
wait $BLOB_PID
echo "Blob stopped"
else
echo "Blob was not running"
fi
echo "Downloading Blob.jar..."
wget http://ci.ribesg.fr/job/Blob/lastSuccessfulBuild/artifact/target/Blob.jar -O /home/blob/Blob.jar
echo "Done"
echo "Removing dead screens"
screen -wipe
echo "Checking 'runblob' screen existence"
if ! screen -list | awk '{print $1}' | grep -q "runblob"; then
echo "Not found, creating 'runblob' screen"
screen -d -m -S runblob
fi
echo "Running Blob.jar... on screen 'runblob'..."
screen -S runblob -p 0 -X stuff "$BLOB_CMD
"
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment