Skip to content

Instantly share code, notes, and snippets.

@chuyskywalker
Last active December 30, 2015 02:39
Show Gist options
  • Save chuyskywalker/7764614 to your computer and use it in GitHub Desktop.
Save chuyskywalker/7764614 to your computer and use it in GitHub Desktop.
Directory Structure:
- /gits/<repo>
- /www/<site base>/
- /www/<site base>/pages (docroot)
- /www/<site base>/conf.d/ (config files)
# recreate/update cron tab
touch /etc/cron.d/site-crons
chown root.root /etc/cron.d/site-crons
chmod 644 /etc/cron.d/site-crons
cat /www/*/conf.d/crontab > /etc/cron.d/site-crons
# restart it, because I am paranoid
/etc/init.d/crond restart
echo "Cron file recreated"
/etc/init.d/nginx stop
/etc/init.d/php-fpm-5.5 restart
/etc/init.d/nginx start
echo 'nginx/php restarted'
#!/bin/sh
GIT_WORK_TREE=/www/repo git checkout -f
check_changes()
{
FILES=`git diff --name-only $1..$2`
for FILE in $FILES; do
case "$FILE" in
conf.d/conf.nginx)
echo 'Restarting nginx'
sudo /gits/nginx-restart.sh
;;
conf.d/crontab)
echo 'Updating cron'
sudo /gits/cron-update.sh
;;
conf.d/supervisor.ini)
echo 'Updating/restarting supervisor'
sudo /gits/supervisord-update.sh
;;
*)
echo "Updated: $FILE"
;;
esac
done;
}
while read oldrev newrev refname
do
# echo "REVS: " $oldrev $newrev $refname
check_changes $oldrev $newrev $refname
done
echo 'Deployed'
supervisorctl update
echo 'supervisord updated'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment