This commit is contained in:
2021-08-02 17:31:24 +08:00
parent a095c94e21
commit 9ad35eb88a
3 changed files with 384 additions and 288 deletions
+16 -20
View File
@@ -28,21 +28,21 @@ abstract class Server
/**
* @param $prefix
* @throws ConfigException
*/
protected function setProcessName($prefix)
{
if (Snowflake::getPlatform()->isMac()) {
return;
}
$name = Config::get('id', 'system-service');
if (!empty($prefix)) {
$name .= '.' . $prefix;
}
swoole_set_process_name($name);
}
/**
* @param $prefix
* @throws ConfigException
*/
protected function setProcessName($prefix)
{
if (Snowflake::getPlatform()->isMac()) {
return;
}
$name = Config::get('id', 'system-service');
if (!empty($prefix)) {
$name .= '.' . $prefix;
}
swoole_set_process_name($name);
}
/**
@@ -63,11 +63,7 @@ abstract class Server
public function setEvents(string $name, ?array $events): void
{
if (is_array($events) && is_string($events[0])) {
$reflect = Snowflake::getDi()->getReflect($events[0]);
if (!$reflect) {
throw new Exception('Checks the class is c\'not instantiable.');
}
$events[0] = $reflect->newInstance();
$events[0] = Snowflake::getDi()->get($events[0]);
}
if (!is_callable($events)) {
return;