diff --git a/Kafka/Kafka.php b/Kafka/Kafka.php index 6382899a..68e2de8d 100644 --- a/Kafka/Kafka.php +++ b/Kafka/Kafka.php @@ -44,7 +44,7 @@ class Kafka extends \Snowflake\Process\Process private function waite(array $kafkaServer) { try { - name('Kafka Consumer ' . $kafkaServer['topic']); + name($this->pid, 'Kafka Consumer ' . $kafkaServer['topic']); [$config, $topic, $conf] = $this->kafkaConfig($kafkaServer); if (empty($config) && empty($topic) && empty($conf)) { diff --git a/System/Crontab/Consumer.php b/System/Crontab/Consumer.php index a1771feb..8f1d905f 100644 --- a/System/Crontab/Consumer.php +++ b/System/Crontab/Consumer.php @@ -5,7 +5,11 @@ namespace Snowflake\Crontab; use Exception; +use ReflectionException; use Snowflake\Event; +use Snowflake\Exception\ComponentException; +use Snowflake\Exception\ConfigException; +use Snowflake\Exception\NotFindClassException; use Snowflake\Process\Process; use Snowflake\Snowflake; use Swoole\Coroutine; @@ -28,7 +32,7 @@ class Consumer extends Process public function onHandler(\Swoole\Process $process): void { if (Snowflake::getPlatform()->isLinux()) { - $process->name('Crontab consumer'); + name($this->pid, 'Crontab consumer'); } $this->channel = new Coroutine\Channel(2000); @@ -66,10 +70,11 @@ class Consumer extends Process /** * @param \Swoole\Process $process - * @throws \ReflectionException - * @throws \Snowflake\Exception\ComponentException - * @throws \Snowflake\Exception\ConfigException - * @throws \Snowflake\Exception\NotFindClassException + * @throws ReflectionException + * @throws ComponentException + * @throws ConfigException + * @throws NotFindClassException + * @throws Exception */ public function tick(\Swoole\Process $process) { diff --git a/System/Crontab/ZookeeperProcess.php b/System/Crontab/ZookeeperProcess.php index d562ad98..ba6dacbb 100644 --- a/System/Crontab/ZookeeperProcess.php +++ b/System/Crontab/ZookeeperProcess.php @@ -49,7 +49,7 @@ class ZookeeperProcess extends Process $crontab->clearAll(); if (Snowflake::getPlatform()->isLinux()) { - $process->name('Crontab zookeeper.'); + name($this->pid, 'Crontab zookeeper.'); } Timer::tick(1000, function () { $startTime = time(); diff --git a/function.php b/function.php index ef5e33ea..0f48a6ab 100644 --- a/function.php +++ b/function.php @@ -586,14 +586,16 @@ if (!function_exists('name')) { * @throws ConfigException * @throws Exception */ - function name(int $pid) + function name(int $pid, string $prefix = null) { if (Snowflake::getPlatform()->isMac()) { return; } $name = Config::get('id', false, 'system') . '[' . $pid . ']'; - + if (!empty($prefix)) { + $name .= $prefix; + } swoole_set_process_name($name); }