Skip to content

Commit c1b5791

Browse files
committed
记录 worker id 到日志文件
1 parent 40489d6 commit c1b5791

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Process.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function waitAll()
126126
if ($id !== false) {
127127
unset(static::$workers[$id]);
128128
}
129-
$this->log("[worker $pid] exited with status $status");
129+
$this->log("[worker.$id $pid] exited with status $status");
130130
}
131131
}
132132

@@ -150,15 +150,15 @@ protected function run()
150150
// Run job.
151151
call_user_func($this->job, $this);
152152
} catch (\Throwable $e) {
153-
$this->log('[worker '. posix_getpid() .'] ' . $e);
153+
$this->log("[worker.{$this->id} {$this->workerPid}] " . $e);
154154
// rerun
155155
$this->run();
156156
}
157157
}
158158

159159
public function handleShutdown()
160160
{
161-
$errmsg = '[worker '. posix_getpid() .'] process terminated';
161+
$errmsg = "[worker.{$this->id} {$this->workerPid}] process terminated";
162162
// Handle last error.
163163
$error = error_get_last();
164164
if ($error) {
@@ -223,7 +223,7 @@ public function signalShutdownHandler($signo)
223223
unset(static::$workers[$id]);
224224
}
225225
} else {
226-
$this->log('[worker '. posix_getpid() .'] ' . $msg);
226+
$this->log("[worker.{$this->id} {$this->workerPid}] " . $msg);
227227

228228
// Worker process exit.
229229
exit(0);

0 commit comments

Comments
 (0)