优化Windows脚本

This commit is contained in:
david 2021-02-04 15:24:05 +08:00
parent eade3677ba
commit 73f8aa4064
6 changed files with 70 additions and 19 deletions

View File

@ -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;
}
}

View File

@ -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()
{}

View File

@ -28,6 +28,7 @@ class Config
'user' => 'user',
'user_sites'=> 'user_sites',
'weixin' => 'weixin',
'userProfile' => 'userProfile',
];
/**

View File

@ -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);

View File

@ -7,5 +7,7 @@
- [ ] 前端实时显示任务运行状态Ajax
- [ ] 一键更新到最新版
- [ ] 跨平台的配置导入导出(任务热刷新)
- [ ] 分批次请求辅种解决客户端做种多辅种失败的问题有的客户端内做种6000个
- [ ] 增加开关,未配置的站点不显示日志
- [ ] 分批次请求辅种解决客户端做种多辅种失败的问题有的客户端内做种60000个
- [ ] 增加开关,未配置的站点不显示日志
- [ ] 开启关闭计划任务
- [ ] 停止执行中的计划任务

View File

@ -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
pause
goto :end
:fail
cls
echo 网络状况不太好呀无法连接API服务器...
pause
:end
echo.