改名
This commit is contained in:
@@ -26,15 +26,11 @@ class OnManagerStart extends Callback
|
|||||||
*/
|
*/
|
||||||
public function onHandler(Server $server)
|
public function onHandler(Server $server)
|
||||||
{
|
{
|
||||||
// Snowflake::setWorkerId($server->manager_pid);
|
Snowflake::setWorkerId($server->manager_pid);
|
||||||
//
|
|
||||||
// $events = Snowflake::app()->getEvent();
|
fire(Event::SERVER_MANAGER_START, [$server]);
|
||||||
// $events->trigger(Event::SERVER_MANAGER_START, [$server]);
|
|
||||||
//
|
name('Server Manager.');
|
||||||
// if (!Snowflake::getPlatform()->isLinux()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// name(Config::get('id', false, 'system') . ' Server Manager.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ class OnWorkerStart extends Callback
|
|||||||
* @param int $worker_id
|
* @param int $worker_id
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ConfigException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onHandler(Server $server, int $worker_id): void
|
public function onHandler(Server $server, int $worker_id): void
|
||||||
@@ -41,6 +40,8 @@ class OnWorkerStart extends Callback
|
|||||||
$attribute->read(directory('app'), 'App');
|
$attribute->read(directory('app'), 'App');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->set_process_name($server, $worker_id);
|
||||||
|
|
||||||
if ($worker_id >= $server->setting['worker_num']) {
|
if ($worker_id >= $server->setting['worker_num']) {
|
||||||
$this->onTask($server, $worker_id);
|
$this->onTask($server, $worker_id);
|
||||||
} else {
|
} else {
|
||||||
@@ -53,24 +54,20 @@ class OnWorkerStart extends Callback
|
|||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param int $worker_id
|
* @param int $worker_id
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
* @throws ConfigException
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onTask(Server $server, int $worker_id)
|
public function onTask(Server $server, int $worker_id)
|
||||||
{
|
{
|
||||||
putenv('environmental=' . Snowflake::TASK);
|
putenv('environmental=' . Snowflake::TASK);
|
||||||
|
|
||||||
fire(Event::SERVER_TASK_START);
|
fire(Event::SERVER_TASK_START);
|
||||||
|
|
||||||
$this->set_process_name($server, $worker_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param int $worker_id
|
* @param int $worker_id
|
||||||
* @param $prefix
|
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
* @throws ConfigException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onWorker(Server $server, int $worker_id)
|
public function onWorker(Server $server, int $worker_id)
|
||||||
@@ -84,29 +81,21 @@ class OnWorkerStart extends Callback
|
|||||||
$this->addError($exception);
|
$this->addError($exception);
|
||||||
write($exception->getMessage(), 'worker');
|
write($exception->getMessage(), 'worker');
|
||||||
}
|
}
|
||||||
$this->set_process_name($server, $worker_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $socket
|
* @param $socket
|
||||||
* @param $worker_id
|
* @param $worker_id
|
||||||
* @return string
|
|
||||||
* @throws ConfigException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function set_process_name($socket, $worker_id): mixed
|
private function set_process_name($socket, $worker_id): void
|
||||||
{
|
{
|
||||||
$prefix = Config::get('id', false, 'system');
|
|
||||||
if ($worker_id >= $socket->setting['worker_num']) {
|
if ($worker_id >= $socket->setting['worker_num']) {
|
||||||
$name = $prefix . ' Task: No.' . $worker_id;
|
name('Task: No.' . $worker_id);
|
||||||
} else {
|
} else {
|
||||||
$name = $prefix . ' worker: No.' . $worker_id;
|
name('Worker: No.' . $worker_id);
|
||||||
}
|
}
|
||||||
if (Snowflake::getPlatform()->isMac()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return swoole_set_process_name($name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-6
@@ -46,16 +46,12 @@ class Kafka extends \Snowflake\Process\Process
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $kafkaServer
|
* @param array $kafkaServer
|
||||||
* @throws ComponentException
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function waite(array $kafkaServer)
|
private function waite(array $kafkaServer)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$prefix = rtrim(Snowflake::app()->id, ':');
|
name('Kafka Consumer ' . $kafkaServer['topic']);
|
||||||
|
|
||||||
if (!Snowflake::getPlatform()->isMac()) {
|
|
||||||
swoole_set_process_name($prefix . ' 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,6 +10,7 @@ use HttpServer\Http\Request;
|
|||||||
use HttpServer\Http\Response;
|
use HttpServer\Http\Response;
|
||||||
use HttpServer\Route\Router;
|
use HttpServer\Route\Router;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Error\Logger;
|
use Snowflake\Error\Logger;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
@@ -566,6 +567,9 @@ if (!function_exists('name')) {
|
|||||||
if (Snowflake::getPlatform()->isMac()) {
|
if (Snowflake::getPlatform()->isMac()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = Config::get('id', false, 'system') .' '. $name;
|
||||||
|
|
||||||
swoole_set_process_name($name);
|
swoole_set_process_name($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user