Skip to content

Instantly share code, notes, and snippets.

@octalmage
Created September 11, 2014 04:51
Show Gist options
  • Save octalmage/01c702473e2af6c4a2ee to your computer and use it in GitHub Desktop.
Save octalmage/01c702473e2af6c4a2ee to your computer and use it in GitHub Desktop.
Automatically restart HHVM if a url is returning a 502. I'm using the HHVM nightlies to take advantage of some new features, but it will occasionally stop responding to requests. Add this to your crontab to run every minute.
#!/bin/bash
response=$(curl -L --write-out %{http_code} --silent --output /dev/null jason.stallin.gs);
echo $response
if [ "$response" = "502" ]
then
service hhvm restart
fi
@renege
Copy link

renege commented Dec 23, 2014

Looks promising. Because I still get 502 sometimes. How to use this? I'm not sure if * * * * * /root/autorestart.sh wil work as a cronjob

@octalmage
Copy link
Author

That worked for me! Sorry just saw this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment