Created
August 15, 2014 00:33
-
-
Save alchemycs/af5a03a02d7b986ee60c to your computer and use it in GitHub Desktop.
Apache Config Auto-Watch via Upstart
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
# apache-config-watch - checks config changes and reloads apache if the configs are ok | |
description "Reload apache when configs have changed." | |
author "Michael McHugh <[email protected]>" | |
start on runlevel [2345] | |
stop on runlevel [016] | |
respawn | |
exec /opt/CompliSpace/bin/apache-config-watcher.sh |
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 | |
# DO NOT RUN THIS MANUALY | |
# This script is used by upstart and run as a dameon at boot time | |
while inotifywait -qre close_write -e modify -e move -e delete -e create /etc/apache2/sites-enabled; do | |
TMP=$(mktemp) | |
apache2ctl configtest &>$TMP | |
cat $TMP | grep -q "Syntax OK" | |
if [ $? -eq 0 ] | |
then | |
echo "$(date): Syntax is OK, reloading" | |
service apache2 reload | |
else | |
echo "$(date): Syntax is BAD, fix it first!" | |
fi | |
# cat $TMP | |
rm $TMP | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment