Browse Source

update: complete process manager

master
dnomd343 2 years ago
parent
commit
8f85d04325
  1. 2
      Dockerfile
  2. 16
      main.php
  3. 2
      src/Logger.php
  4. 24
      src/Process.php

2
Dockerfile

@ -21,7 +21,7 @@ RUN sed -i '/blahblah/i\return 0;' config.m4 && \
mkdir -p /iconv/lib/php8/modules/ && mv ./modules/iconv.so /iconv/lib/php8/modules/
FROM alpine:3.16
RUN apk add --no-cache nginx php8 php8-fpm php8-iconv
RUN apk add --no-cache nginx php8 php8-fpm php8-iconv php8-pcntl
COPY --from=iconv /iconv/ /usr/
COPY --from=vlmcsd /tmp/vlmcs* /usr/bin/
EXPOSE 1688/tcp 1689/tcp

16
src/demo.php → main.php

@ -1,8 +1,10 @@
<?php
require_once 'Daemon.php';
require_once 'Logger.php';
require_once 'Process.php';
$version = 'dev';
require_once './src/Daemon.php';
require_once './src/Logger.php';
require_once './src/Process.php';
$nginx = array(
'name' => 'nginx',
@ -24,12 +26,18 @@ $vlmcsd = array(
declare(ticks = 1);
pcntl_signal(SIGCHLD, 'subExit'); // receive SIGCHLD signal
logging::info('Loading kms-server (' . $version . ')');
new Process($nginx['command']);
logging::info('Start nginx server...OK');
new Process($phpFpm['command']);
logging::info('Start php-fpm server...OK');
new Process($vlmcsd['command']);
logging::info('Start vlmcsd server...OK');
logging::info('Enter the daemon process');
while (true) {
msSleep(3000); // sleep 3s
msSleep(5000); // sleep 5s
daemon($nginx);
daemon($phpFpm);
daemon($vlmcsd);

2
src/Logger.php

@ -1,6 +1,6 @@
<?php
logging::$logLevel = logging::DEBUG;
logging::$logLevel = logging::INFO;
$logColor = array(
logging::DEBUG => '37m', // white

24
src/Process.php

@ -56,27 +56,3 @@ class Process {
return proc_close($this->process); // return status code
}
}
//$p = new Process(['sleep', '10'], $capture = true);
//echo "PID -> $p->pid\n";
//
//echo "Alive -> " . ($p->isAlive() ? 'yes' : 'no') . "\n";
//echo "Sleep 5s...\n";
//sleep(5);
//
//echo "Alive -> " . ($p->isAlive() ? 'yes' : 'no') . "\n";
//echo "Send kill signal\n";
//$p->signal(15);
//sleep(1);
//echo "Alive -> " . ($p->isAlive() ? 'yes' : 'no') . "\n";
//
//echo '--------------------------------------------' . PHP_EOL;
//echo $p->getStdout();
//echo '--------------------------------------------' . PHP_EOL;
//echo $p->getStdout();
//echo '--------------------------------------------' . PHP_EOL;
//echo $p->getStderr();
//echo '--------------------------------------------' . PHP_EOL;
//
//echo "Return code -> " . $p->quit() . "\n";

Loading…
Cancel
Save