Skip to content

Instantly share code, notes, and snippets.

@liaol
Created January 20, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liaol/60b4d6fbebc334220441 to your computer and use it in GitHub Desktop.
Save liaol/60b4d6fbebc334220441 to your computer and use it in GitHub Desktop.
beego project deploy script
#! /bin/bash
function log() {
echo -e "\033[32m $1 \033[0m"
}
log "starting deploy"
appname="appname"
path="/deploy/project"
src_path=$path"/src"
version=`date +%Y%m%d%H%M%S`
log "pull code"
cd $src_path
git reset HEAD --hard
git pull origin master
cd $path
log "starting build"
bee pack -p src -o build -ba "-o ${appname}"
log "decomporess"
tar -C app/ -xzf build/src.tar.gz
mv build/src.tar.gz build/$version.tar.gz
log "replace conf"
/bin/cp -rf conf/* app/conf/
log "rsync"
#改成对应的
rsync -avur app/ user@ip:/path -e 'ssh -p port -i id_rsa_file' --delete --compress --no-perms --no-owner --no-group
log "clean"
rm -rf app/*
log "all done"
#! /bin/bash
binary_file=/path/to/binary_file
#存md5值的文件
md5_file=/path/md5
old_md5=`cat $md5_file`
new_md5=`md5sum "${binary_file}" | awk '{print $1}'`
if [ $old_md5 != $new_md5 ]
then
echo $new_md5 > $md5_file
/usr/bin/supervisorctl restart yourapp
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment