Skip to content

Instantly share code, notes, and snippets.

@luffyke
Created February 8, 2017 07:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luffyke/790154ec5142abd9fd6245a5fd8b9427 to your computer and use it in GitHub Desktop.
Save luffyke/790154ec5142abd9fd6245a5fd8b9427 to your computer and use it in GitHub Desktop.
beego deploy shell
#! /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