-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.php
More file actions
35 lines (30 loc) · 972 Bytes
/
service.php
File metadata and controls
35 lines (30 loc) · 972 Bytes
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
<?php
/*//php vendor/iry/php-event/service.php 你的服务脚本
if(substr(PHP_SAPI_NAME(),0,3) !== 'cli'){
exit("请在CLI下运行 / The program runs only in CLI mode!");
}
$file=$argv[1];
$script = basename($file);
$dir = dirname($file);
//计算工作目录并且换 / Calculate and change the working directory
if($dir!='.'){
if (strpos($dir,'..')===0){
$dir = realpath(rtrim(getcwd(),DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$dir);
}
chdir($dir);//切换目录
echo "工作目录已经切换到【". getcwd(). "】\n";
}else{
echo "工作目录:【". getcwd(). "】\n";
}
function start($script,$sleep){
for ($i=$sleep; $i>0;$i--) {
echo $i." 秒后启动 / Start in $i seconds\r";
sleep(1);
}
passthru('php '.$script);//避免修改代码后需要重启
}
//您的脚本退出后 该服务会自动重启你的进程
while (1){
start($script,1);
//exit;
}*/