modify
This commit is contained in:
@@ -9,6 +9,7 @@ use HttpServer\Abstracts\Callback;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Coroutine\System;
|
||||
use Swoole\Server;
|
||||
|
||||
@@ -32,10 +33,7 @@ class OnWorkerStart extends Callback
|
||||
putenv('state=start');
|
||||
putenv('worker=' . $worker_id);
|
||||
|
||||
$content = System::readFile(storage('runtime.php'));
|
||||
|
||||
$annotation = Snowflake::app()->getAnnotation();
|
||||
$annotation->setLoader(unserialize($content));
|
||||
$annotation = $this->settings();
|
||||
if ($worker_id < $server->setting['worker_num']) {
|
||||
$this->onWorker($server, $annotation);
|
||||
} else {
|
||||
@@ -44,6 +42,21 @@ class OnWorkerStart extends Callback
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Annotation\Annotation
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function settings(): Annotation
|
||||
{
|
||||
$content = System::readFile(storage('runtime.php'));
|
||||
|
||||
$annotation = Snowflake::app()->getAnnotation();
|
||||
$annotation->setLoader(unserialize($content));
|
||||
|
||||
return $annotation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $worker_id
|
||||
|
||||
@@ -115,7 +115,11 @@ class Server extends HttpService
|
||||
|
||||
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION);
|
||||
|
||||
Coroutine::set(['enable_deadlock_check' => false]);
|
||||
$settings['enable_deadlock_check'] = false;
|
||||
$settings['exit_condition'] = function () {
|
||||
return Coroutine::stats()['coroutine_num'] === 0;
|
||||
};
|
||||
Coroutine::set($settings);
|
||||
|
||||
return $this->execute($baseServer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user