#! /bin/sh

log() {
    LINE="$(date +"%FT%T") $@"
    echo $LINE >> /var/log/apache2/apache2.log
}
log "Shutting down httpd and it's children"
/bin/pkill -f "httpd -k start" -9
log "Removing potentially stale pid file"
rm -f /var/apache2/run/httpd.pid
log "Starting apache2"
OUT=$(/usr/local/apache2/bin/apachectl -k start 2>&1)
if [ $? -ne 0 ]; then
    log "Failed to start apache:"
    log "$OUT"
fi
