-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathprocessmanager
More file actions
executable file
·61 lines (49 loc) · 1.54 KB
/
processmanager
File metadata and controls
executable file
·61 lines (49 loc) · 1.54 KB
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
#!/usr/bin/env php
<?php
/*
* 入口脚本
* 使用方法:php processmanager -s stop -c member.php
* @author xiaoliang
* 您可以自由使用该源码,但是在使用过程中,请保留作者信息。尊重他人劳动成果就是尊重自己
* */
define('PROCESS_PATH', __DIR__. '/../');
date_default_timezone_set('Asia/Shanghai');
require PROCESS_PATH . '/vendor/autoload.php';
$globalConfig = require_once PROCESS_PATH . '/globalConfig.php';
$param = getopt('s:c:');
$opt =$param['s'] ?? '';
$configFile =$param['c'] ?? die('找不到配置文件') ;
// 业务工作目录
$workConfigDir = $globalConfig['workerDir'];
if ( !file_exists( $workConfigDir )) {
die('业务目录不存在');
} else {
$configFile = $workConfigDir . '/' . $configFile;
}
if ($configFile && file_exists($configFile)) {
$config = require_once $configFile;
} else {
die('找不到配置文件.');
}
// 处理配置数据
if ( isset( $config['exec'] ) ) {
foreach( $config['exec'] as $k => &$v ) {
if ( isset( $v['files'] ) && !empty( $v['files'] ) ) {
$v['name'] = parseScriptToName( $v['files'] );
}
}
}
// 静态配饰和业务配置合并
$config = array_merge( $globalConfig, $config );
//print_r( $config );
//exit;
$console = new \Clever\ProcessManager\Console($opt, $config);
$console->run();
// 解析exec->files脚本名称
function parseScriptToName( $files ) {
if ( empty( $files ) ) {
return '';
}
$fileName = strstr( $files, '/' );
return substr( $fileName, 1, strlen($fileName) );
}