Last active
December 18, 2015 18:29
-
-
Save bilal/5825908 to your computer and use it in GitHub Desktop.
A script to restart Seyren
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 | |
CURRENT_USER=`id -u -n` | |
echo $CURRENT_USER | |
# kill the jetty/java process | |
su ec2-user -c 'kill -9 `pidof java`; JAVAPID=`pidof java | wc -l`; while [ $JAVAPID -ne 0 ]; do sleep 1; kill -9 `pidof java`; JAVAPID=`pidof java | wc -l`; done' | |
echo "Killed Seyren process\n" | |
logfile=/home/ec2-user/seyren_restarter.log | |
exec >> $logfile 2>&1 | |
cd /opt/ | |
cd scobal-seyren-* | |
# removing old logs | |
rm -rf nohup.out | |
rm -rf seyren*.log | |
# setup environment variables | |
su ec2-user -c 'source ~/.bashrc; nohup java -jar seyren-web/target/dependency/jetty-runner.jar --path /seyren seyren-web/target/*.war 2>&1 &' | |
sleep 3 | |
JAVAPID=`pidof java | wc -l` | |
D=`date` | |
if [ $JAVAPID -eq 1 ] | |
then | |
echo "Successfully restarted seyren at $D" | |
else | |
echo "Unable to start seyren at $D" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment