Skip to content

Commit

Permalink
增加sdb获取定时任务
Browse files Browse the repository at this point in the history
  • Loading branch information
何平 committed Feb 2, 2024
1 parent 2001a49 commit 266e5f8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cloud-admin/SDB/Business/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private function analyzeHandler(
} else {
// method,uri,name,action,middleware
$registeredMiddlewares = MiddlewareManager::get('http', $uri, $method);
$middlewares = $this->config->get('middlewares.' . 'http', []);
$middlewares = $this->config->get('middlewares.http', []);

$middlewares = array_merge($middlewares, $registeredMiddlewares);
$middlewares = MiddlewareManager::sortMiddlewares($middlewares);
Expand Down
3 changes: 3 additions & 0 deletions cloud-admin/SDB/WebSocketDebugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Exception;
use Hyperf\Codec\Json;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Crontab\CrontabManager;
use Hyperf\Redis\Pool\PoolFactory;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
Expand Down Expand Up @@ -49,6 +50,7 @@
use function CloudAdmin\Utils\logger;
use function count;
use function ctype_print;
use function dump;
use function explode;
use function Hyperf\Support\env;
use function Hyperf\Support\make;
Expand Down Expand Up @@ -180,6 +182,7 @@ public function start(): void
case Opcode::TEXT:
$in = $frame->getPayloadData()->getContents();

dump(di()->get(CrontabManager::class)->getCrontabs());
if ($in === "\n") {
$in = $this->getLastCommand();
}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"hyperf/config": "~3.1.0",
"hyperf/constants": "~3.1.0",
"hyperf/contract": "~3.1.0",
"hyperf/crontab": "^3.1",
"hyperf/db-connection": "~3.1.0",
"hyperf/di": "~3.1.0",
"hyperf/dispatcher": "~3.1.0",
Expand Down
22 changes: 22 additions & 0 deletions config/autoload/crontab.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);
/**
* This file is part of Cloud-Admin project.
*
* @link https://www.cloud-admin.jayjay.cn
* @document https://wiki.cloud-admin.jayjay.cn
* @license https://github.com/swow-cloud/swow-admin/blob/master/LICENSE
*/
use Hyperf\Crontab\Crontab;

return [
'enable' => true,
// 通过配置文件定义的定时任务
'crontab' => [
// Closure 类型定时任务 (仅在 Coroutine style server 中支持)
(new Crontab())->setType('closure')->setName('Closure')->setRule('*/ * * * *')->setCallback(function () {
\var_dump(\date('Y-m-d H:i:s'), 111111111);
})->setEnvironments('production'),
],
];
10 changes: 10 additions & 0 deletions config/autoload/processes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@
* @document https://wiki.cloud-admin.jayjay.cn
* @license https://github.com/swow-cloud/swow-admin/blob/master/LICENSE
*/
use Hyperf\Crontab\Process\CrontabDispatcherProcess;

/**
* This file is part of Cloud-Admin project.
*
* @see https://www.cloud-admin.jayjay.cn
* @document https://wiki.cloud-admin.jayjay.cn
* @license https://github.com/swow-cloud/swow-admin/blob/master/LICENSE
*/
return [
CrontabDispatcherProcess::class,
];
2 changes: 1 addition & 1 deletion test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Hyperf\Contract\ApplicationInterface;
use Hyperf\Di\ClassLoader;

/**
/*
* This file is part of Cloud-Admin project.
*
* @see https://www.cloud-admin.jayjay.cn
Expand Down

0 comments on commit 266e5f8

Please sign in to comment.