We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1acdcc commit a80945bCopy full SHA for a80945b
README.md
@@ -106,7 +106,9 @@ return [
106
'class' => \Dacheng\Yii2\Swoole\Log\CoroutineFileTarget::class,
107
'levels' => ['error', 'warning'],
108
'logFile' => '@runtime/logs/app.log',
109
- 'channelSize' => 10000,
+ 'maxFileSize' => 10240, // KB
110
+ 'maxLogFiles' => 5,
111
+ 'enableRotation' => true,
112
],
113
114
@@ -230,11 +232,11 @@ curl http://127.0.0.1:9501/
230
232
'targets' => [
231
233
[
234
- 'channelSize' => 10000, // Channel buffer size
- 'pushTimeout' => 0.5, // Timeout for pushing to channel
235
- 'batchSize' => 1000, // Messages per batch write
+ 'levels' => ['error', 'warning'],
236
+ 'logFile' => '@runtime/logs/app.log',
237
'maxFileSize' => 10240, // Max file size before rotation (KB)
238
'maxLogFiles' => 5, // Number of rotated files to keep
239
+ 'enableRotation' => true, // Enable log rotation
240
241
242
examples/app-api/config/console.php
@@ -20,9 +20,6 @@
20
'levels' => ['error', 'warning', 'info'],
21
'exportInterval' => 1,
22
'logFile' => '@runtime/logs/console.log',
23
- 'channelSize' => (int)(getenv('YII_LOG_CHANNEL_SIZE') ?: 10000),
24
- 'pushTimeout' => 0.5,
25
- 'batchSize' => 1000, // Packets per batch write
26
'maxFileSize' => 10240, // 10MB
27
'maxLogFiles' => 5,
28
'enableRotation' => true,
examples/app-api/config/web.php
@@ -37,9 +37,6 @@
37
38
39
40
41
42
- 'batchSize' => 1000,
43
'maxFileSize' => 10240,
44
45
examples/app-api/controllers/LogController.php
@@ -199,8 +199,6 @@ public function actionStats()
199
$lineCount = count(file($logFile));
200
}
201
202
- $channelStats = $logTarget->getChannelStats();
203
-
204
$result = [
205
'success' => true,
206
'log_file' => $logFile,
@@ -210,15 +208,10 @@ public function actionStats()
210
208
'line_count' => $lineCount,
211
209
'max_file_size_kb' => $logTarget->maxFileSize,
212
'max_log_files' => $logTarget->maxLogFiles,
213
- 'channel_size' => $logTarget->channelSize,
214
- 'push_timeout' => $logTarget->pushTimeout,
215
'rotation_enabled' => $logTarget->enableRotation,
+ 'worker_initialized' => $logTarget->getWorker() !== null,
216
];
217
218
- if ($channelStats !== null) {
219
- $result['channel'] = $channelStats;
220
- }
221
222
return $result;
223
224
examples/app-basic/config/console.php
@@ -35,9 +35,6 @@
35
36
examples/app-basic/config/web.php
@@ -53,9 +53,6 @@
53
54
55
56
57
58
59
60
61
src/Console/SwooleController.php
@@ -64,7 +64,20 @@ public function actionStart(?string $host = null, ?string $port = null): int
64
65
$this->stdout(sprintf("Swoole HTTP server listening on %s:%d\n", $server->host, $server->port));
66
67
- $server->start();
+ try {
68
+ $server->start();
69
+ } catch (\Swoole\ExitException $e) {
70
+ // ExitException is thrown during graceful shutdown, this is expected
71
+ $exitCode = method_exists($e, 'getStatus') ? $e->getStatus() : 0;
72
+
73
+ if ($exitCode === 0) {
74
+ $this->stdout("Swoole HTTP server stopped gracefully.\n");
75
+ return ExitCode::OK;
76
+ }
77
78
+ $this->stderr(sprintf("Swoole HTTP server exited with code %d: %s\n", $exitCode, $e->getMessage()));
79
+ return $exitCode;
80
81
82
return ExitCode::OK;
83
0 commit comments