改名
This commit is contained in:
@@ -40,12 +40,11 @@ class OnWorkerStart extends Callback
|
|||||||
annotation()->read(APP_PATH . 'app', 'App');
|
annotation()->read(APP_PATH . 'app', 'App');
|
||||||
$this->debug(sprintf('scan app dir use time %s', microtime(true) - $start));
|
$this->debug(sprintf('scan app dir use time %s', microtime(true) - $start));
|
||||||
|
|
||||||
$prefix = sprintf('%s #%d Pid:%d start.', ucfirst(env('environmental')), $worker_id, $server->worker_pid);
|
|
||||||
|
|
||||||
if ($worker_id >= $server->setting['worker_num']) {
|
if ($worker_id >= $server->setting['worker_num']) {
|
||||||
$this->onTask($server, $worker_id, $prefix);
|
$this->onTask($server, $worker_id);
|
||||||
} else {
|
} else {
|
||||||
$this->onWorker($server, $worker_id, $prefix);
|
$this->onWorker($server, $worker_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +56,12 @@ class OnWorkerStart extends Callback
|
|||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public function onTask(Server $server, int $worker_id, $prefix)
|
public function onTask(Server $server, int $worker_id)
|
||||||
{
|
{
|
||||||
putenv('environmental=' . Snowflake::TASK);
|
putenv('environmental=' . Snowflake::TASK);
|
||||||
|
|
||||||
|
$prefix = sprintf('%s #%d Pid:%d start.', ucfirst(env('environmental')), $worker_id, $server->worker_pid);
|
||||||
|
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
fire(Event::SERVER_TASK_START);
|
fire(Event::SERVER_TASK_START);
|
||||||
@@ -78,10 +79,13 @@ class OnWorkerStart extends Callback
|
|||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onWorker(Server $server, int $worker_id, $prefix)
|
public function onWorker(Server $server, int $worker_id)
|
||||||
{
|
{
|
||||||
Snowflake::setWorkerId($server->worker_pid);
|
Snowflake::setWorkerId($server->worker_pid);
|
||||||
putenv('environmental=' . Snowflake::WORKER);
|
putenv('environmental=' . Snowflake::WORKER);
|
||||||
|
|
||||||
|
$prefix = sprintf('%s #%d Pid:%d start.', ucfirst(env('environmental')), $worker_id, $server->worker_pid);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
fire(Event::SERVER_WORKER_START, [$worker_id]);
|
fire(Event::SERVER_WORKER_START, [$worker_id]);
|
||||||
|
|||||||
Reference in New Issue
Block a user