510742 发表于 2010 年 10 月 2 日 17:27:32

Nginx 遇到 502 Bad Gateway 自动重启脚本



放到crontab里一分钟执行一次。URL和CMD根据自己的改。
#!/usr/bin/php
<?
$url = 'http://www.diahosting.com';
$cmd = '/usr/local/php/sbin/php-fpm restart';
for($i = 0; $i < 5; $i ++){
$exec = "curl --connect-timeout 3 -I $url 2>/dev/null";
$res = shell_exec($exec);
if(stripos($res, '502 Bad Gateway') !== false){
shell_exec($cmd);
exit();
}
}
?>
至于crontab,请自行Google搜索

页: [1]
查看完整版本: Nginx 遇到 502 Bad Gateway 自动重启脚本