2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

兼容node app启动重启

This commit is contained in:
e 2022-06-27 12:04:27 +08:00
parent eba8bd4259
commit d204e0c964

View File

@ -195,7 +195,7 @@ export async function updateMiaoPlugin(e) {
cwd: `${_path}/plugins/xiaoyao-cvs-plugin/` cwd: `${_path}/plugins/xiaoyao-cvs-plugin/`
}, function(error, stdout, stderr) { }, function(error, stdout, stderr) {
//console.log(stdout); //console.log(stdout);
if (/Already up to date/.test(stdout)) { if (/Already up[ -]to[ -]date/.test(stdout)) {
e.reply("目前已经是最新版图鉴插件了~"); e.reply("目前已经是最新版图鉴插件了~");
return true; return true;
} }
@ -211,19 +211,22 @@ export async function updateMiaoPlugin(e) {
}), { }), {
EX: 30 EX: 30
}); });
timer = setTimeout(function() { timer = setTimeout(function () {
let command = "npm run restart"; let command = `npm run start`;
exec(command, function(error, stdout, stderr) { if (process.argv[1].includes("pm2")) {
if (error) { command = `npm run restart`;
if (/Yunzai not found/.test(error)) { }
e.reply("自动重启失败,请手动重启以应用新版图鉴插件。请使用 npm run start 命令启动Yunzai-Bot"); exec(command, function (error, stdout, stderr) {
} else { if (error) {
e.reply("重启失败!\nError code: " + error.code + "\n" + error.stack + e.reply("自动重启失败,请手动重启以应用新版图鉴插件。\nError code: " + error.code + "\n" + error.stack + "\n");
"\n 请稍后重试。"); Bot.logger.error('重启失败\n${error.stack}');
} return true;
return true; } else if (stdout) {
} Bot.logger.mark("重启成功运行已转为后台查看日志请用命令npm run log");
}) Bot.logger.mark("停止后台运行命令npm stop");
process.exit();
}
})
}, 1000); }, 1000);
}); });