modify
This commit is contained in:
@@ -23,7 +23,7 @@ use Rpc\Service;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Crontab\Consumer;
|
||||
use Snowflake\Crontab\CrontabZookeeperProcess;
|
||||
use Snowflake\Crontab\ZookeeperProcess;
|
||||
use Snowflake\Error\LoggerProcess;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
@@ -133,10 +133,7 @@ class Server extends HttpService
|
||||
public function start(): string
|
||||
{
|
||||
$configs = Config::get('servers', true);
|
||||
if (Config::get('crontab.enable') === true) {
|
||||
$this->addProcess('CrontabZookeeper', CrontabZookeeperProcess::class);
|
||||
$this->addProcess('CrontabConsumer', Consumer::class);
|
||||
}
|
||||
|
||||
$baseServer = $this->initCore($configs);
|
||||
if (!$baseServer) {
|
||||
return 'ok';
|
||||
|
||||
@@ -463,7 +463,6 @@ abstract class BaseApplication extends Service
|
||||
'jwt' => ['class' => Jwt::class],
|
||||
'async' => ['class' => Async::class],
|
||||
'filter' => ['class' => HttpFilter::class],
|
||||
'crontab' => ['class' => \Snowflake\Crontab\Producer::class],
|
||||
'object' => ['class' => ObjectPool::class],
|
||||
'goto' => ['class' => BaseGoto::class],
|
||||
'rpc' => ['class' => \Rpc\Producer::class],
|
||||
|
||||
@@ -20,6 +20,7 @@ use Snowflake\Abstracts\BaseApplication;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Abstracts\Input;
|
||||
use Snowflake\Abstracts\Kernel;
|
||||
use Snowflake\Crontab\CrontabProviders;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Exception\NotFindPropertyException;
|
||||
@@ -54,6 +55,10 @@ class Application extends BaseApplication
|
||||
$this->import(ConsoleProviders::class);
|
||||
$this->import(DatabasesProviders::class);
|
||||
$this->import(ServerProviders::class);
|
||||
|
||||
if (Config::get('crontab.enable') !== true) {
|
||||
$this->import(CrontabProviders::class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Snowflake\Crontab;
|
||||
|
||||
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Abstracts\Providers;
|
||||
use Snowflake\Application;
|
||||
|
||||
|
||||
/**
|
||||
* Class CrontabProviders
|
||||
* @package Snowflake\Crontab
|
||||
*/
|
||||
class CrontabProviders extends Providers
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Application $application
|
||||
*/
|
||||
public function onImport(Application $application)
|
||||
{
|
||||
$server = $application->getServer();
|
||||
if (Config::get('crontab.enable') !== true) {
|
||||
return;
|
||||
}
|
||||
$application->set('crontab', ['class' => Producer::class]);
|
||||
|
||||
$server->addProcess('CrontabZookeeper', ZookeeperProcess::class);
|
||||
$server->addProcess('Consumer', Consumer::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,10 +17,10 @@ use Swoole\Coroutine\Channel;
|
||||
use Swoole\Timer;
|
||||
|
||||
/**
|
||||
* Class CrontabZookeeperProcess
|
||||
* Class ZookeeperProcess
|
||||
* @package Snowflake\Process
|
||||
*/
|
||||
class CrontabZookeeperProcess extends Process
|
||||
class ZookeeperProcess extends Process
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user