-
Notifications
You must be signed in to change notification settings - Fork 55
/
daemonmng.php
executable file
·126 lines (110 loc) · 4.1 KB
/
daemonmng.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
header('Content-Type: text/HTML; charset=utf-8');
define('IN_GAME', TRUE);
define('GAME_ROOT', dirname(__FILE__).'/');
error_reporting(0);
$magic_quotes_gpc = get_magic_quotes_gpc();
require GAME_ROOT.'./include/global.func.php';
require GAME_ROOT.'./include/modulemng/modulemng.config.php';
require GAME_ROOT.'./include/socket.func.php';
//游戏内也有调用需求
if(empty($_GET['in_game_pass']) || $_GET['in_game_pass'] != substr(base64_encode($___MOD_CONN_PASSWD),0,6)){
check_authority();
}
$___TEMP_runmode = 'Admin';
$___TEMP_CONN_PORT = -1;
if (isset($_GET['action']) && $_GET['action']=='restart')
{
__STOP_ALL_SERVER__();
touch(GAME_ROOT.'./gamedata/tmp/server/request_new_root_server');
__SOCKET_LOG__("已请求脚本启动一台新的服务器。");
header('Location: daemonmng.php');
}
if (isset($_GET['action']) && $_GET['action']=='stopall')
{
__STOP_ALL_SERVER__();
header('Location: daemonmng.php');
}
if (isset($_GET['action']) && strpos($_GET['action'],'stop')===0)
{
$sid = substr($_GET['action'],4);
if(is_numeric($sid)){
__STOP_SINGLE_SERVER__($sid);
}
header('Location: daemonmng.php');
}
echo '<br><span><font size=5>Daemon管理系统</font></span><br><br>';
if (!$___MOD_SRV)
echo '<font color="red">目前不处于Daemon模式下。</font><br><br>';
echo '管理脚本状况: ';
$t1=(int)file_get_contents(GAME_ROOT.'./gamedata/tmp/server/scriptalive.txt');
$t2=(int)filemtime(GAME_ROOT.'./gamedata/tmp/server/scriptalive.txt');
$t=max($t1,$t2);
$ff=1;
if (time()-$t<=10)
{
echo '<font color="green">正在运行</font><br>';
}
else
{
echo '<font color="red">不在运行</font><br><br>';
echo '<font color="blue">请从服务器shell中启动./acdts-daemonctl.sh(Linux)或者启动./acdts-daemonctl.bat(WIN)</font><br>';
$ff = 0;
}
echo '<br>';
if ($handle=opendir(GAME_ROOT.'./gamedata/tmp/server'))
{
$flag=0; $srvlist=Array(); $chosen=-1;
while (($sid=readdir($handle))!==false)
{
if ($sid=='.' || $sid=='..') continue;
$sid=(int)$sid;
if ($sid<$___MOD_CONN_PORT_LOW || $sid>$___MOD_CONN_PORT_HIGH) continue;
if (is_dir(GAME_ROOT.'./gamedata/tmp/server/'.(string)$sid))
array_push($srvlist,$sid);
}
echo '有'.count($srvlist).'个进程正在运行。<br><br>';
if ($ff && isset($_GET['action']) && $_GET['action']=='start' && count($srvlist)==0)
{
touch(GAME_ROOT.'./gamedata/tmp/server/request_new_root_server');
__SOCKET_LOG__("已请求脚本启动一台新的服务器。");
header('Location: daemonmng.php');
}
if ($ff && count($srvlist)==0 && $___MOD_SRV)
{
echo '点击启动一个新的根进程。<br>
(有几秒的延迟,请等待几秒然后刷新页面)<br><a href="daemonmng.php?action=start" style="text-decoration: none"><span>
<font color="green">[启动]</font></span></a>';
die();
}
$i=0;
foreach ($srvlist as $key)
{
$i++;
$r=__SEND_TOUCH_CMD__($key);
if ($r == 'ok' || $r=='ok_root')
{
if ($r=='ok')
echo " 进程 {$i}: 端口 <font color=\"blue\">{$key}</font> 状态 ";
else echo " [根] 进程 {$i}: 端口 <font color=\"blue\">{$key}</font> 状态 ";
echo '<font color="green">正常</font>';
}
else
{
echo " 进程 {$i}: 端口 <font color=\"blue\">{$key}</font> 状态 ";
echo '<font color="red">异常</font> 错误信息:'.$r;
}
echo ' <a href="daemonmng.php?action=stop'.$key.'"><font color="red">[关闭]</font></a>';
echo '<br>';
}
if ($ff)
{
echo '<br>点击下面的按钮可以杀死所有进程,<br>如果处于Daemon模式(或于未来重新开启Daemon模式时),<br>一个新的根进程将被自动重新启动。<br>
(有几秒的延迟,请等待几秒然后刷新页面)<br>
<a href="daemonmng.php?action=restart" style="text-decoration: none"><span><font color="red">[重启所有进程]</font></span></a><br>';
}
echo '<br>点击下面的按钮可以杀死所有进程。<br>
<a href="daemonmng.php?action=stopall" style="text-decoration: none"><span><font color="red">[杀死所有进程]</font></span></a><br>';
}
else echo '无法打开gamedata/tmp/server目录。';
?>