Last active
December 30, 2015 02:39
-
-
Save chuyskywalker/7764614 to your computer and use it in GitHub Desktop.
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
Directory Structure: | |
- /gits/<repo> | |
- /www/<site base>/ | |
- /www/<site base>/pages (docroot) | |
- /www/<site base>/conf.d/ (config files) | |
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
# 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" |
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
/etc/init.d/nginx stop | |
/etc/init.d/php-fpm-5.5 restart | |
/etc/init.d/nginx start | |
echo 'nginx/php restarted' |
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/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' |
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
supervisorctl update | |
echo 'supervisord updated' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment