mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
Merge pull request #36 from SirlyDreamer/master
#喵喵更新 的自动重启功能适配node app方式启动的Yunzai-Bot
This commit is contained in:
commit
3997455983
@ -182,15 +182,19 @@ export async function updateMiaoPlugin(e) {
|
|||||||
qq: e.user_id
|
qq: e.user_id
|
||||||
}), { EX: 30 });
|
}), { EX: 30 });
|
||||||
timer = setTimeout(function () {
|
timer = setTimeout(function () {
|
||||||
let command = "npm run restart";
|
let command = `npm run start`;
|
||||||
|
if (process.argv[1].includes("pm2")) {
|
||||||
|
command = `npm run restart`;
|
||||||
|
}
|
||||||
exec(command, function (error, stdout, stderr) {
|
exec(command, function (error, stdout, stderr) {
|
||||||
if (error) {
|
if (error) {
|
||||||
if (/Yunzai not found/.test(error)) {
|
e.reply("自动重启失败,请手动重启以应用新版喵喵。\nError code: " + error.code + "\n" + error.stack + "\n");
|
||||||
e.reply("自动重启失败,请手动重启以应用新版喵喵。请使用 npm run start 命令启动Yunzai-Bot");
|
Bot.logger.error('重启失败\n${error.stack}');
|
||||||
} else {
|
|
||||||
e.reply("重启失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
} else if (stdout) {
|
||||||
|
Bot.logger.mark("重启成功,运行已转为后台,查看日志请用命令:npm run log");
|
||||||
|
Bot.logger.mark("停止后台运行命令:npm stop");
|
||||||
|
process.exit();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
Loading…
Reference in New Issue
Block a user