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)
{
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)) {
+10 -5
View File
@@ -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)
{
+1 -1
View File
@@ -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();
+4 -2
View File
@@ -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);
}