Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] fix workman some bug #1

Closed
millken opened this issue Jun 7, 2014 · 1 comment
Closed

[PATCH] fix workman some bug #1

millken opened this issue Jun 7, 2014 · 1 comment
Labels

Comments

@millken
Copy link

millken commented Jun 7, 2014

diff --git a/Core/Lib/Checker.php b/Core/Lib/Checker.php
index 0018413..7489b6f 100755
--- a/Core/Lib/Checker.php
+++ b/Core/Lib/Checker.php
@@ -272,7 +272,7 @@ class Checker
     public static function checkPidFile()
     {
         // 已经有进程pid可能server已经启动
-        if(@file_get_contents(WORKERMAN_PID_FILE))
+        if(is_file(WORKERMAN_PID_FILE) && file_get_contents(WORKERMAN_PID_FILE))
         {
             \Man\Core\Master::notice("\033[33;40mWorkerman already started\033[0m", true);
             exit;
diff --git a/Core/Master.php b/Core/Master.php
index da0e084..e4c4423 100755
--- a/Core/Master.php
+++ b/Core/Master.php
@@ -344,6 +344,7 @@ class Master
                 if(self::createOneWorker($worker_name) == 0)
                 {
                     self::notice("Worker exit unexpected");
+                    sleep(5);
                     exit(500);
                 }
             }
diff --git a/Core/SocketWorker.php b/Core/SocketWorker.php
index d469096..51d3691 100755
--- a/Core/SocketWorker.php
+++ b/Core/SocketWorker.php
@@ -201,7 +201,7 @@ abstract class SocketWorker extends AbstractWorker
         $this->installSignal();

         // 触发该worker进程onStart事件,该进程整个生命周期只触发一次
-        if($this->onStart())
+        if(!$this->onStart())
         {
             return;
         }
@@ -230,7 +230,7 @@ abstract class SocketWorker extends AbstractWorker
     public function stop()
     {
         // 触发该worker进程onStop事件
-        if($this->onStop())
+        if(!$this->onStop())
         {
             return;
         }
diff --git a/bin/workermand b/bin/workermand
index 9a687f5..43fa9a5 100755
--- a/bin/workermand
+++ b/bin/workermand
@@ -172,7 +172,8 @@ function force_kill()

 function stop_and_wait($wait_time = 6)
 {
-    $pid = @file_get_contents(WORKERMAN_PID_FILE);
+    $pid = "";
+    if(is_file(WORKERMAN_PID_FILE)) $pid = file_get_contents(WORKERMAN_PID_FILE);
     if(empty($pid))
     {
         //exit("server not running?\n");
@walkor
Copy link
Owner

walkor commented Jun 9, 2014

感谢你的issue,以上并非是workerman的bug。

@walkor walkor closed this as completed Jun 9, 2014
@walkor walkor added the invalid label Jun 15, 2015
walkor pushed a commit that referenced this issue Mar 22, 2016
walkor pushed a commit that referenced this issue Apr 26, 2017
walkor pushed a commit that referenced this issue Oct 13, 2017
walkor pushed a commit that referenced this issue Oct 17, 2017
Merge walkor/Workerman
walkor pushed a commit that referenced this issue Oct 21, 2017
walkor pushed a commit that referenced this issue Jul 29, 2019
walkor pushed a commit that referenced this issue Nov 13, 2019
walkor pushed a commit that referenced this issue Nov 23, 2019
pull the latest version of Workerman
walkor pushed a commit that referenced this issue Mar 5, 2020
walkor pushed a commit that referenced this issue Feb 10, 2022
lengqiuqiuqiu pushed a commit to lengqiuqiuqiu/workerman that referenced this issue Jan 27, 2025
walkor added a commit that referenced this issue Jan 27, 2025
解析的时候可能会报错substr(): Argument #1 ($string) must be of type string, bool given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants