Explorar o código

Merge pull request #1026 from akotulu/master

Improved logging when process exits and php select exceeds file descr…
walkor hai 1 ano
pai
achega
c330b08df0
Modificáronse 2 ficheiros con 9 adicións e 9 borrados
  1. 4 4
      src/Events/Select.php
  2. 5 5
      src/Worker.php

+ 4 - 4
src/Events/Select.php

@@ -187,9 +187,9 @@ final class Select implements EventInterface
     {
         $count = count($this->readFds);
         if ($count >= 1024) {
-            echo "Warning: system call select exceeded the maximum number of connections 1024, please install event/libevent extension for more connections.\n";
+            trigger_error("System call select exceeded the maximum number of connections 1024, please install event/libevent extension for more connections.", E_USER_WARNING);
         } else if (DIRECTORY_SEPARATOR !== '/' && $count >= 256) {
-            echo "Warning: system call select exceeded the maximum number of connections 256.\n";
+            trigger_error("System call select exceeded the maximum number of connections 256.", E_USER_WARNING);
         }
         $fdKey = (int)$stream;
         $this->readEvents[$fdKey] = $func;
@@ -216,9 +216,9 @@ final class Select implements EventInterface
     {
         $count = count($this->writeFds);
         if ($count >= 1024) {
-            echo "Warning: system call select exceeded the maximum number of connections 1024, please install event/libevent extension for more connections.\n";
+            trigger_error("System call select exceeded the maximum number of connections 1024, please install event/libevent extension for more connections.", E_USER_WARNING);
         } else if (DIRECTORY_SEPARATOR !== '/' && $count >= 256) {
-            echo "Warning: system call select exceeded the maximum number of connections 256.\n";
+            trigger_error("System call select exceeded the maximum number of connections 256.", E_USER_WARNING);
         }
         $fdKey = (int)$stream;
         $this->writeEvents[$fdKey] = $func;

+ 5 - 5
src/Worker.php

@@ -1265,12 +1265,12 @@ class Worker
             case SIGHUP:
             case SIGTSTP:
                 static::$gracefulStop = false;
-                static::stopAll();
+                static::stopAll(0, "received signal: $signal");
                 break;
             // Graceful stop.
             case SIGQUIT:
                 static::$gracefulStop = true;
-                static::stopAll();
+                static::stopAll(0, "received signal: $signal");
                 break;
             // Reload.
             case SIGUSR2:
@@ -1791,8 +1791,8 @@ class Worker
                 }
             }
 
-            // If shutdown state and all child processes exited then master process exit.
-            if (static::$status === static::STATUS_SHUTDOWN && !static::getAllWorkerPids()) {
+            // If shutdown state and all child processes exited, then master process exit.
+            if (static::$status === static::STATUS_SHUTDOWN && empty(static::getAllWorkerPids())) {
                 static::exitAndClearAll();
             }
         }
@@ -1926,7 +1926,7 @@ class Worker
         static::$status = static::STATUS_SHUTDOWN;
         // For master process.
         if (DIRECTORY_SEPARATOR === '/' && static::$masterPid === posix_getpid()) {
-            static::log("Workerman[" . basename(static::$startFile) . "] stopping ...");
+            static::log("Workerman[" . basename(static::$startFile) . "] stopping, code [$code]");
             $workerPidArray = static::getAllWorkerPids();
             // Send stop signal to all child processes.
             $sig = static::getGracefulStop() ? SIGQUIT : SIGINT;