mirror of https://github.com/dnomd343/kms-server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
2 years ago
|
#!/usr/bin/env php8
|
||
2 years ago
|
<?php
|
||
|
|
||
2 years ago
|
$version = 'v1.2.0-rc2';
|
||
2 years ago
|
|
||
|
require_once './src/Daemon.php';
|
||
|
require_once './src/Logger.php';
|
||
|
require_once './src/Process.php';
|
||
2 years ago
|
|
||
|
$nginx = array(
|
||
2 years ago
|
'name' => 'nginx',
|
||
2 years ago
|
'command' => ['/usr/sbin/nginx'],
|
||
2 years ago
|
'pidFile' => '/run/nginx.pid',
|
||
2 years ago
|
);
|
||
|
|
||
2 years ago
|
$phpFpm = array(
|
||
|
'name' => 'php-fpm8',
|
||
|
'command' => ['/usr/sbin/php-fpm8'],
|
||
|
'pidFile' => '/run/php-fpm8.pid',
|
||
|
);
|
||
|
|
||
|
$vlmcsd = array(
|
||
|
'name' => 'vlmcsd',
|
||
|
'command' => ['/usr/bin/vlmcsd', '-e', '-p', '/run/vlmcsd.pid'],
|
||
|
'pidFile' => '/run/vlmcsd.pid',
|
||
|
);
|
||
|
|
||
|
declare(ticks = 1);
|
||
2 years ago
|
pcntl_signal(SIGCHLD, function() { // receive SIGCHLD signal
|
||
|
pcntl_wait($status, WNOHANG); // avoid zombie process
|
||
|
});
|
||
2 years ago
|
pcntl_signal(SIGTERM, function() { // receive SIGTERM signal
|
||
|
global $nginx, $phpFpm, $vlmcsd;
|
||
|
logging::info('Get SIGTERM -> exit');
|
||
|
subExit($nginx['pidFile'], $phpFpm['pidFile'], $vlmcsd['pidFile']);
|
||
|
});
|
||
|
pcntl_signal(SIGINT, function() { // receive SIGINT signal
|
||
|
global $nginx, $phpFpm, $vlmcsd;
|
||
|
logging::info('Get SIGINT -> exit');
|
||
|
subExit($nginx['pidFile'], $phpFpm['pidFile'], $vlmcsd['pidFile']);
|
||
|
});
|
||
2 years ago
|
|
||
2 years ago
|
if (in_array('--debug', $argv)) { // enter debug mode
|
||
|
logging::$logLevel = logging::DEBUG;
|
||
|
}
|
||
|
|
||
|
logging::info('Loading kms-server (' . $version . ')');
|
||
2 years ago
|
new Process($nginx['command']);
|
||
2 years ago
|
logging::info('Start nginx server...OK');
|
||
2 years ago
|
new Process($phpFpm['command']);
|
||
2 years ago
|
logging::info('Start php-fpm server...OK');
|
||
2 years ago
|
new Process($vlmcsd['command']);
|
||
2 years ago
|
logging::info('Start vlmcsd server...OK');
|
||
|
|
||
2 years ago
|
logging::info('Enter daemon process');
|
||
|
while (true) { // start daemon
|
||
|
for ($i = 0; $i < 500; $i++) { // sleep 5s
|
||
|
msDelay(10); // return main loop every 10ms
|
||
|
}
|
||
2 years ago
|
daemon($nginx);
|
||
|
daemon($phpFpm);
|
||
|
daemon($vlmcsd);
|
||
2 years ago
|
}
|