From 73f8aa4064057f53f186215380a36a9844eba69d Mon Sep 17 00:00:00 2001 From: david Date: Thu, 4 Feb 2021 15:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Windows=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/Config.php | 12 ++++++----- app/domain/Command.php | 13 +++++++++--- app/domain/Config.php | 1 + app/domain/Crontab.php | 10 ++------- todo.md | 6 ++++-- windows_start.cmd | 47 +++++++++++++++++++++++++++++++++++++++++- 6 files changed, 70 insertions(+), 19 deletions(-) diff --git a/app/common/Config.php b/app/common/Config.php index 30e0245..bf9353d 100644 --- a/app/common/Config.php +++ b/app/common/Config.php @@ -29,9 +29,14 @@ class Config if (empty($filename)) { return false; } - $file_name = $absolutePath ? $filename : static::createFilePath($filename, $type); clearstatcache(); + if ($absolutePath) { + $dir = dirname($filename); + is_dir($dir) or mkdir($dir, 0777, true); + } + + $file_name = $absolutePath ? $filename : static::createFilePath($filename, $type); if (file_exists($file_name)) { chmod($file_name, 0777); } @@ -67,8 +72,8 @@ class Config if (empty($filename)) { return $default; } - $file_name = $absolutePath ? $filename : static::createFilePath($filename, $type); + $file_name = $absolutePath ? $filename : static::createFilePath($filename, $type); clearstatcache(); if (is_file($file_name)) { switch (strtolower($type)) { @@ -119,9 +124,6 @@ class Config public static function createFilePath(string $name = '', string $type = 'array'):string { $ext = isset(self::extMap[$type]) ? self::extMap[$type] : self::extMap['object']; - clearstatcache(); - is_dir(db_path()) or mkdir(db_path(), 0777, true); - return db_path() . DIRECTORY_SEPARATOR . $name . $ext; } } diff --git a/app/domain/Command.php b/app/domain/Command.php index a22301d..510759f 100644 --- a/app/domain/Command.php +++ b/app/domain/Command.php @@ -13,14 +13,21 @@ class Command $taskType = $param['type'] ?? null; switch ($taskType) { case 'reseed': - return PHP_BINARY . ' ' . BASE_PATH . DIRECTORY_SEPARATOR . 'bin/iyuu.php '.$param['uuid']; + return self::Reseed($param); default: return 'date'; } } - public static function Reseed() - {} + /** + * 辅种任务 + * @param array $param + * @return string + */ + public static function Reseed(array $param):string + { + return PHP_BINARY . ' ' . BASE_PATH . DIRECTORY_SEPARATOR . 'bin/iyuu.php '.$param['uuid']; + } public static function Download() {} diff --git a/app/domain/Config.php b/app/domain/Config.php index c65a44d..2c171fb 100644 --- a/app/domain/Config.php +++ b/app/domain/Config.php @@ -28,6 +28,7 @@ class Config 'user' => 'user', 'user_sites'=> 'user_sites', 'weixin' => 'weixin', + 'userProfile' => 'userProfile', ]; /** diff --git a/app/domain/Crontab.php b/app/domain/Crontab.php index 2ea4a82..f5bb273 100644 --- a/app/domain/Crontab.php +++ b/app/domain/Crontab.php @@ -67,20 +67,14 @@ class Crontab */ public static function onWorkerStart() { - // db目录 - if(!is_dir(db_path())) - { - mkdir(db_path(), 0777, true); - } - // 初始化目录 $sys_dir = [self::cron_dir, self::run_dir, self::pid_dir, self::lock_dir, self::log_dir]; array_walk($sys_dir, function ($v, $k){ $dir = cron_path() . DIRECTORY_SEPARATOR . $v; - !is_dir($dir) and mkdir($dir, 0777, true); + is_dir($dir) or mkdir($dir, 0777, true); }); - // 初始化计划任务文件[不同平台的配置导入,会造成command错误,需要重新解析命令] + // 初始化计划任务文件[不同平台的配置,会造成command错误,需要重新解析命令] $cron = Conf::get(domainConfig::filename['crontab'], Constant::config_format, []); array_walk($cron, function ($v, $k){ self::createHock($v); diff --git a/todo.md b/todo.md index e28e6f2..604e655 100644 --- a/todo.md +++ b/todo.md @@ -7,5 +7,7 @@ - [ ] 前端实时显示任务运行状态(Ajax) - [ ] 一键更新到最新版 - [ ] 跨平台的配置导入导出(任务热刷新) -- [ ] 分批次请求辅种,解决客户端做种多辅种失败的问题(有的客户端内做种6000个) -- [ ] 增加开关,未配置的站点不显示日志 \ No newline at end of file +- [ ] 分批次请求辅种,解决客户端做种多辅种失败的问题(有的客户端内做种60000个) +- [ ] 增加开关,未配置的站点不显示日志 +- [ ] 开启关闭计划任务 +- [ ] 停止执行中的计划任务 \ No newline at end of file diff --git a/windows_start.cmd b/windows_start.cmd index ef091dd..1ef61f8 100644 --- a/windows_start.cmd +++ b/windows_start.cmd @@ -1,4 +1,49 @@ @echo off +title IYUUPlus +cd /d "%~dp0" chcp 65001 + +:ping +echo 正在为您检查本机网络情况耐心等待... +echo. +ping demo.iyuu.cn | find "超时" > NUL && goto fail +ping demo.iyuu.cn | find "目标主机" > NUL && goto fail +echo 本机网络良好…… +goto :git + + +:git +git --version|find "git version">nul&&goto :pull +cls +echo 当前IYUUPlus运行环境未检测到git程序,不支持自动更新。 +echo 推荐您使用git来下载整个代码库! +echo 您可以在安装git程序后,在命令行内输入: +echo git clone https://gitee.com/ledc/iyuuplus.git +goto :start + + +:pull +echo 正在为您自动更新... +git --version +git fetch --all +git reset --hard origin/master +echo 升级完成! +goto :start + + +:start +echo. +echo 停止程序:CTRL + C php %~dp0start.php %~dp0task.php -pause \ No newline at end of file +pause +goto :end + + +:fail +cls +echo 网络状况不太好呀,无法连接API服务器... +pause + + +:end +echo. \ No newline at end of file