This commit is contained in:
2021-03-29 11:36:09 +08:00
parent fe6c754857
commit 118ac9efe5
4 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ class Kafka extends \Snowflake\Process\Process
private function waite(array $kafkaServer) private function waite(array $kafkaServer)
{ {
try { try {
name('Kafka Consumer ' . $kafkaServer['topic']); name($this->pid, 'Kafka Consumer ' . $kafkaServer['topic']);
[$config, $topic, $conf] = $this->kafkaConfig($kafkaServer); [$config, $topic, $conf] = $this->kafkaConfig($kafkaServer);
if (empty($config) && empty($topic) && empty($conf)) { if (empty($config) && empty($topic) && empty($conf)) {
+10 -5
View File
@@ -5,7 +5,11 @@ namespace Snowflake\Crontab;
use Exception; use Exception;
use ReflectionException;
use Snowflake\Event; use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Process\Process; use Snowflake\Process\Process;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Coroutine; use Swoole\Coroutine;
@@ -28,7 +32,7 @@ class Consumer extends Process
public function onHandler(\Swoole\Process $process): void public function onHandler(\Swoole\Process $process): void
{ {
if (Snowflake::getPlatform()->isLinux()) { if (Snowflake::getPlatform()->isLinux()) {
$process->name('Crontab consumer'); name($this->pid, 'Crontab consumer');
} }
$this->channel = new Coroutine\Channel(2000); $this->channel = new Coroutine\Channel(2000);
@@ -66,10 +70,11 @@ class Consumer extends Process
/** /**
* @param \Swoole\Process $process * @param \Swoole\Process $process
* @throws \ReflectionException * @throws ReflectionException
* @throws \Snowflake\Exception\ComponentException * @throws ComponentException
* @throws \Snowflake\Exception\ConfigException * @throws ConfigException
* @throws \Snowflake\Exception\NotFindClassException * @throws NotFindClassException
* @throws Exception
*/ */
public function tick(\Swoole\Process $process) public function tick(\Swoole\Process $process)
{ {
+1 -1
View File
@@ -49,7 +49,7 @@ class ZookeeperProcess extends Process
$crontab->clearAll(); $crontab->clearAll();
if (Snowflake::getPlatform()->isLinux()) { if (Snowflake::getPlatform()->isLinux()) {
$process->name('Crontab zookeeper.'); name($this->pid, 'Crontab zookeeper.');
} }
Timer::tick(1000, function () { Timer::tick(1000, function () {
$startTime = time(); $startTime = time();
+4 -2
View File
@@ -586,14 +586,16 @@ if (!function_exists('name')) {
* @throws ConfigException * @throws ConfigException
* @throws Exception * @throws Exception
*/ */
function name(int $pid) function name(int $pid, string $prefix = null)
{ {
if (Snowflake::getPlatform()->isMac()) { if (Snowflake::getPlatform()->isMac()) {
return; return;
} }
$name = Config::get('id', false, 'system') . '[' . $pid . ']'; $name = Config::get('id', false, 'system') . '[' . $pid . ']';
if (!empty($prefix)) {
$name .= $prefix;
}
swoole_set_process_name($name); swoole_set_process_name($name);
} }