diff --git a/src/app/Application.php b/src/app/Application.php index f1fcf12..675b03f 100644 --- a/src/app/Application.php +++ b/src/app/Application.php @@ -73,7 +73,7 @@ function isDarkMode() { if(!TaskerManager::has("App心跳守护进程")){ - TaskerManager::add(TaskerTime::hour(0),new DaemonTasker(),"App心跳守护进程",-1); + TaskerManager::add(TaskerTime::nMinute(1),new DaemonTasker(),"App心跳守护进程",-1); } diff --git a/src/app/task/DaemonTasker.php b/src/app/task/DaemonTasker.php index 171ecad..5866de3 100644 --- a/src/app/task/DaemonTasker.php +++ b/src/app/task/DaemonTasker.php @@ -13,8 +13,10 @@ namespace app\task; +use app\controller\api\App; use cleanphp\base\Config; use cleanphp\cache\Cache; +use cleanphp\file\Log; use library\mail\AnkioMail; use library\task\TaskerAbstract; use Throwable; @@ -35,6 +37,7 @@ public function getTimeOut(): int */ public function onStart() { + $last = Cache::init()->get("last_heart"); $online = false; if (time() - $last <= 60 * 15) { @@ -44,6 +47,7 @@ public function onStart() $file = AnkioMail::compileNotify("#e74c3c", "#fff", Config::getConfig("login")['image'],"Vpay", "App客户端心跳掉线", "
App客户端心跳掉线,请检查手机端监控
最后心跳时间:" . date("Y-m-d H:i:s", $last) . "
"); AnkioMail::send(Config::getConfig("mail")['received'], "App客户端心跳掉线", $file, "Vpay"); } + \cleanphp\App::$debug && Log::record("Daemon","App心跳检测完成"); } diff --git a/src/app/view/error/error.tpl b/src/app/view/error/error.tpl index 5c395f1..7de80ca 100644 --- a/src/app/view/error/error.tpl +++ b/src/app/view/error/error.tpl @@ -17,14 +17,14 @@ /> {if $theme == "dark"} - + {else} - + {/if} {* *} - + diff --git a/src/cleanphp/helper.php b/src/cleanphp/helper.php index 9f9a665..4b20d90 100644 --- a/src/cleanphp/helper.php +++ b/src/cleanphp/helper.php @@ -16,6 +16,7 @@ use cleanphp\base\Dump; use cleanphp\base\Route; use cleanphp\closure\SerializableClosure; +use cleanphp\file\Log; use cleanphp\process\Async; use cleanphp\process\AsyncObject; @@ -230,7 +231,8 @@ function __unserialize(string $data, array $options = null) SerializableClosure::unwrapClosures($data); SerializableClosure::exitContext(); }catch (\cleanphp\exception\NoticeException $exception){ - return $data; + Log::record("__unserialize", "反序列化错误:".$exception->getMessage()); + return null; } return $data; } diff --git a/src/library/task/TaskInfo.php b/src/library/task/TaskInfo.php index 3b039fe..525f8c1 100644 --- a/src/library/task/TaskInfo.php +++ b/src/library/task/TaskInfo.php @@ -22,5 +22,5 @@ class TaskInfo public int $next = 0;//下次的执行时间 public bool $loop = false;//是否循环 public int $times = 0;//循环次数 - public ?TaskerAbstract $closure = null;//序列化的执行事件 + public ?string $closure = null;//序列化的执行事件 } \ No newline at end of file diff --git a/src/library/task/TaskerManager.php b/src/library/task/TaskerManager.php index d15e547..001797d 100755 --- a/src/library/task/TaskerManager.php +++ b/src/library/task/TaskerManager.php @@ -157,7 +157,7 @@ public static function add(string $cron, TaskerAbstract $taskerAbstract, string $task->key = uniqid("task_"); $task->next = CronExpression::factory($cron)->getNextRunDate()->getTimestamp(); - $task->closure = $taskerAbstract; + $task->closure = __serialize($taskerAbstract); $list = self::getList(); $list[] = $task; Cache::init(0, Variables::getCachePath("tasker", DS))->set("tasker_list", $list); @@ -176,6 +176,7 @@ public static function run() { $data = self::getList(); + App::$debug && Log::record("Tasker", "当前定时任务列表:".print_r($data,true)); /** * @var $value TaskInfo */ @@ -192,7 +193,7 @@ public static function run() /** * @var TaskerAbstract $task */ - $task = $value->closure; + $task = __unserialize($value->closure); $timeout = $task->getTimeOut(); go(function () use ($task) {