-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstart.php
executable file
·83 lines (75 loc) · 1.67 KB
/
start.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
include_once('agent.php');
include_once('issue.php');
include_once('conn.php');
include_once('CheckIssue.php');
include_once('CheckWorker.php');
//$szuid = getmypid();
$file_array = parse_ini_file("dmconfig.ini",true);
$hostname = $file_array['hostname'];
$con = new Conn();
$redis = $con->RedisConByArr($file_array);
if(!$redis){
echo "start连接失败";
exit;
}
//$redis->set($hostname.'_agent',$szuid);
//echo "agentID:".$szuid;
//调度worker
$issuepid = pcntl_fork();
if($issuepid == -1){
echo "创建Issue失败,发生错误";
exit(1);
}
if(!$issuepid){
$issuegpid = pcntl_fork();
echo "issueID:".$issuegpid;
if(!$issuegpid){
$issue = new Issue($file_array);
$issue->run();
}
exit;
pcntl_wait($status);
}
//检测进程CheckIssue
$pid = pcntl_fork();
if($issuepid == -1){
echo "创建CheckIssue失败,发生错误";
exit(1);
}
if(!$pid){
$gpid = pcntl_fork();
echo "CheckIssueID:".$gpid;
if(!$gpid){
$uid = posix_getpid();
$checkissue = new CheckIssue($file_array);
$redis->set($hostname.'_issue_ppi',$uid);
$checkissue->run();
}
exit;
pcntl_wait($status);
}
//检测进程CheckWorker
$pid = pcntl_fork();
if($issuepid == -1){
echo "创建CheckWorker失败,发生错误";
exit(1);
}
if(!$pid){
$gpid = pcntl_fork();
echo "CheckWorkerID:".$gpid;
if(!$gpid){
$uid = posix_getpid();
$checkworker = new CheckWorker($file_array);
$redis->set($hostname.'_worker_ppw',$uid);
$checkworker->run();
}
exit;
pcntl_wait($status);
}
//Conn::RedisPclose($redis);
//$agent = new agent($file_array);
$agent = new agent($file_array);
$agent->register();
$agent->agentsub();
?>