From 8f85d0432591adca60b494816b551f809a19d22e Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Wed, 10 Aug 2022 16:02:19 +0800 Subject: [PATCH] update: complete process manager --- Dockerfile | 2 +- src/demo.php => main.php | 16 ++++++++++++---- src/Logger.php | 2 +- src/Process.php | 24 ------------------------ 4 files changed, 14 insertions(+), 30 deletions(-) rename src/demo.php => main.php (63%) diff --git a/Dockerfile b/Dockerfile index 5a1d7ce..53b0f2f 100644 --- a/Dockerfile +++ b/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 diff --git a/src/demo.php b/main.php similarity index 63% rename from src/demo.php rename to main.php index 67c2662..c68b0bd 100644 --- a/src/demo.php +++ b/main.php @@ -1,8 +1,10 @@ '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); diff --git a/src/Logger.php b/src/Logger.php index 1129ca4..14f3cb6 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -1,6 +1,6 @@ '37m', // white diff --git a/src/Process.php b/src/Process.php index 7fafb23..ea3d867 100644 --- a/src/Process.php +++ b/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";