Skip to content

Commit a3b2295

Browse files
committed
删除 Throwable 类定义
1 parent b8d06bb commit a3b2295

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Process.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ protected function setsid()
115115

116116
protected function redirectStd()
117117
{
118+
$logFile = $this->logFile ?: '/dev/null';
119+
118120
// redirect stdin to /dev/null
119121
// redirect stdout, stderr to $logFile
120122
fclose(STDIN);
121123
fclose(STDOUT);
122124
fclose(STDERR);
123125

124-
$logFile = $this->logFile ?: '/dev/null';
125-
126126
global $stdin, $stdout, $stderr;
127127
$stdin = fopen('/dev/null', 'r');
128128
$stdout = fopen($logFile, 'a');
@@ -172,8 +172,11 @@ protected function run()
172172
$this->log("[worker:{$this->id} {$this->workerPid}] process started");
173173
// Run job.
174174
call_user_func($this->job, $this);
175+
} catch (\Exception $e) {
176+
$this->log("[worker:{$this->id} {$this->workerPid}] $e");
177+
exit(250);
175178
} catch (\Throwable $e) {
176-
$this->log("[worker:{$this->id} {$this->workerPid}] " . $e);
179+
$this->log("[worker:{$this->id} {$this->workerPid}] $e");
177180
exit(250);
178181
}
179182
}
@@ -193,7 +196,8 @@ public function handleFatalError()
193196
public function log($contents)
194197
{
195198
$time = gettimeofday();
196-
$contents = sprintf("[%s.%s] [master %s] %s\n", date('Y-m-d H:i:s', $time['sec']), $time['usec'], $this->masterPid, $contents);
199+
$usec = str_pad($time['usec'], 6, '0');
200+
$contents = sprintf("[%s.%s] [master %s] %s\n", date('Y-m-d H:i:s', $time['sec']), $usec, $this->masterPid, $contents);
197201
if (!$this->daemonize) {
198202
echo $contents;
199203
}

src/helpers.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
* @author ueaner <[email protected]>
44
*/
55

6-
if (!interface_exists('Throwable') && !class_exists('Throwable')) {
7-
class Throwable extends Exception
8-
{
9-
}
10-
}
11-
126
if (!function_exists('data_segment')) {
137
/**
148
* 数据切分

0 commit comments

Comments
 (0)