cnmt 发表于 2012-6-5 11:42:06

关于自动重启代码的问题。谢谢。

论坛放在http://www.abc.com/bbs/下。当出现502时。只是/bbs/下出现。www.abc.com网站根目录放的是存html网页文件.不会出现502.
https://bbs.vpser.net/viewthread.php?tid=1913&extra=&highlight=%E8%87%AA%E5%8A%A8%E9%87%8D%E5%90%AF&page=1
上面链接里的代码。

$url = 'https://www.vpser.net';   这个是否要改成http://www.abc.com/bbs/
$cmd = '/usr/local/php/sbin/php-fpm restart';    可否改成 /root/lnmp restart
还有最后那个?号是不是应该去掉。

#!/usr/bin/php
<!--?
$url = 'https://www.vpser.net';
$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();
}
}
?>

licess 发表于 2012-6-5 13:11:55

网址改成是php页面是首页的就行,只需重启php-fpm
页: [1]
查看完整版本: 关于自动重启代码的问题。谢谢。