Created
February 8, 2017 07:31
-
-
Save luffyke/790154ec5142abd9fd6245a5fd8b9427 to your computer and use it in GitHub Desktop.
beego deploy shell
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 | |
appconf="conf/app.conf" | |
echo "Please enter your deploy environment (dev/prod):" | |
read -r env | |
if [ $env != "dev" ] && [ $env != "prod" ]; then | |
echo "Please input 'dev' or 'prod'" | |
exit | |
fi | |
runmode=`cat $appconf | grep runmode | awk -F " " '{print $3}'` | |
if [ $env != $runmode ]; then | |
sed -i'.bak' "s:runmode = $runmode:runmode = $env:g" $appconf | |
fi | |
appname=`cat $appconf | grep appname | awk -F " " '{print $3}'` | |
pid=`ps -ef | grep $appname | grep -v grep | awk '{print $2}'` | |
if [ ! -z "$pid" ]; then | |
echo "kill $pid" | |
kill $pid | |
fi | |
echo "Building" | |
go build | |
if [ ! -d "logs" ]; then | |
mkdir -p logs | |
fi | |
nohup ./$appname >> logs/app.log & | |
pid=`ps -ef | grep $appname | grep -v grep | awk '{print $2}'` | |
echo "Done, pid is $pid" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment