-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmonitor.php
34 lines (27 loc) · 875 Bytes
/
monitor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
date_default_timezone_set('Asia/Shanghai');
header('Content-Type: text/html; charset=UTF-8');
ini_set('display_errors', 'On');
error_reporting(E_ERROR); /*E_ALL,E_ERROR*/
define("APPPATH", realpath(dirname(__FILE__) . '/../'));
exec("ps -ef | grep 'monitor.php' | grep -v 'grep'", $out);
if(count($out) > 1) {
die("monitor is running\n");
}
while(1) {
$zoneinfos_array = require(APPPATH . "/application/config/zoneinfo.php");
$zoneinfos = $zoneinfos_array['zone_info'];
unset($zoneinfos_array);
foreach($zoneinfos as $zoneinfo) {
$zone_id = $zoneinfo['zone_id'];
if($zoneinfo['status'] != 1) {
continue;
}
$out = null;
$data = exec("ps -ef | grep 'co_server.php {$zone_id}' | grep -v 'grep'", $out);
if(count($out) == 0) {
exec("/usr/bin/php /data/app/super_server/co_server.php {$zone_id} > /dev/null &", $ret);
}
}
sleep(1);
}