Skip to content

Commit caea27c

Browse files
committed
feat: Managing worker stop and refactoring
1 parent c9b0491 commit caea27c

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/CLI/Adapters/Swoole.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function start($callback): self
2323
$this->pool->set(['enable_coroutine' => true]);
2424

2525
$this->onWorkerStart($callback);
26-
26+
$this->onWorkerStop(fn() => $this->pool->shutdown());
2727
$this->pool->start();
2828
return $this;
2929
}
@@ -45,7 +45,7 @@ public function onWorkerStart($callback): self
4545

4646
public function onWorkerStop(callable $callback): self
4747
{
48-
$this->pool->on('WorkerStart', function (Pool $pool, string $workerId) use ($callback) {
48+
$this->pool->on('WorkerStop', function (Pool $pool, string $workerId) use ($callback) {
4949
call_user_func($callback, $workerId);
5050
});
5151

src/CLI/CLI.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ protected function getParams(Hook $hook): array
290290

291291
$this->validate($key, $param, $value);
292292

293-
$params[$key] = $value;
293+
$key = str_replace('-','_',$key);
294+
$camelCase = \lcfirst(\str_replace('_', '', \ucwords($key, '_')));
295+
296+
$params[$camelCase] = $value;
294297
}
295298

296299
foreach ($hook->getDependencies() as $dependency) {

src/CLI/Task.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class Task extends Hook
1919
public function __construct(string $name)
2020
{
2121
$this->name = $name;
22-
$this->action = function (): void {
23-
};
2422
}
2523

2624
/**

0 commit comments

Comments
 (0)