Last active
December 14, 2015 05:58
-
-
Save kazu634/5038847 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
USER="growth" | |
HOME="/home/${USER}" | |
source $HOME/perl5/perlbrew/etc/bashrc | |
PERLBREW="${HOME}/perl5/perlbrew/bin/perlbrew" | |
PERL=`${PERLBREW} list | grep \* | cut -f 2 -d " "` | |
GROWTHFORECAST=`find ${HOME}/perl5 -type f -name "growthforecast.pl" | grep bin | grep ${PERL}` | |
PID_FILE="/var/run/growthforecast.pid" | |
LOG_FILE="/${HOME}/growthforecast.log" | |
start() { | |
su - ${USER} -c "${PERLBREW} exec perl ${GROWTHFORECAST} --port=5125 \ | |
--data-dir ${HOME}/appdata \ | |
>>$LOG_FILE 2>&1 &" | |
echo `pgrep -o -f 'growthforecast.pl'` >> ${PID_FILE} | |
} | |
stop() { | |
if [ -e $PID_FILE ]; then | |
kill `cat $PID_FILE` | |
rm -f $PID_FILE | |
fi | |
pkill -u growth perl | |
} | |
usage() { | |
echo "Usage: `basename $0` {start|stop|restart}" | |
} | |
case $1 in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
usage | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment