Browse Source

feat: add http switch option

master
Dnomd343 2 years ago
parent
commit
e5a52dda19
  1. 29
      kms.php

29
kms.php

@ -9,6 +9,7 @@ require_once './src/Process.php';
$KMS_PORT = 1688; // kms expose port $KMS_PORT = 1688; // kms expose port
$HTTP_PORT = 1689; // http server port $HTTP_PORT = 1689; // http server port
$ENABLE_HTTP = true; // http interface
$NGINX = array( // nginx process $NGINX = array( // nginx process
'name' => 'nginx', 'name' => 'nginx',
@ -103,21 +104,27 @@ function load_params(): void {
} }
} }
# TODO: add disable http option
function start_process(): void { // start sub processes function start_process(): void { // start sub processes
global $ENABLE_HTTP;
global $NGINX, $PHP_FPM, $VLMCSD; global $NGINX, $PHP_FPM, $VLMCSD;
new Process($NGINX['command']); if ($ENABLE_HTTP) { // http server process
logging::info('Start nginx server...OK'); new Process($NGINX['command']);
new Process($PHP_FPM['command']); logging::info('Start nginx server...OK');
logging::info('Start php-fpm server...OK'); new Process($PHP_FPM['command']);
logging::info('Start php-fpm server...OK');
}
new Process($VLMCSD['command']); new Process($VLMCSD['command']);
logging::info('Start vlmcsd server...OK'); logging::info('Start vlmcsd server...OK');
} }
# TODO: add disable http option function exit_process(): void { // kill sub processes
function exit_process(): void { global $ENABLE_HTTP;
global $NGINX, $PHP_FPM, $VLMCSD; global $NGINX, $PHP_FPM, $VLMCSD;
subExit($NGINX, $PHP_FPM, $VLMCSD); if ($ENABLE_HTTP) {
subExit($NGINX, $PHP_FPM, $VLMCSD); // with http server
} else {
subExit($VLMCSD);
}
} }
declare(ticks = 1); declare(ticks = 1);
@ -154,7 +161,9 @@ while (true) { // start daemon
for ($i = 0; $i < 500; $i++) { // sleep 5s for ($i = 0; $i < 500; $i++) { // sleep 5s
msDelay(10); // return main loop every 10ms msDelay(10); // return main loop every 10ms
} }
daemon($NGINX); if ($ENABLE_HTTP) { // with http server
daemon($PHP_FPM); daemon($NGINX);
daemon($PHP_FPM);
}
daemon($VLMCSD); daemon($VLMCSD);
} }

Loading…
Cancel
Save