noticeUwuzu v6.0@uwuzu1.5.4
This commit is contained in:
+18
-21
@@ -1,29 +1,26 @@
|
||||
import * as fs from "fs";
|
||||
import { format, isAfter } from "date-fns";
|
||||
import { parse } from "date-fns/fp";
|
||||
import { isBefore } from "date-fns/fp";
|
||||
|
||||
import config from "../config.js";
|
||||
import sendMail from "../src/mailer.js";
|
||||
|
||||
const formatParse = parse(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
|
||||
// 初期化
|
||||
if (fs.existsSync("iolog.json") === false) {
|
||||
fs.writeFileSync("iolog.json", JSON.stringify({
|
||||
start: format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"),
|
||||
stop: "",
|
||||
}), "utf-8");
|
||||
}
|
||||
|
||||
export default function successExit() {
|
||||
const iolog = JSON.parse(fs.readFileSync("iolog.json", "utf-8"));
|
||||
// 初期化
|
||||
if (!fs.existsSync("logs/boot.json")) {
|
||||
fs.writeFileSync("logs/boot.json", JSON.stringify({
|
||||
start: new Date(),
|
||||
stop: "",
|
||||
}), "utf-8");
|
||||
}
|
||||
|
||||
const iolog = JSON.parse(fs.readFileSync("logs/boot.json", "utf-8"));
|
||||
|
||||
if (config.emergency.function) {
|
||||
// 前回の終了確認
|
||||
const start = formatParse(iolog.start);
|
||||
const stop = formatParse(iolog.stop);
|
||||
const start = iolog.start;
|
||||
const stop = iolog.stop;
|
||||
|
||||
if (isAfter(start, stop)) {
|
||||
if (isBefore(start, stop)) {
|
||||
console.log("前回の終了が適切でない可能性があります");
|
||||
|
||||
if (config.emergency.mail.function) {
|
||||
@@ -48,15 +45,15 @@ export default function successExit() {
|
||||
}
|
||||
|
||||
// 起動時に起動時刻を保存
|
||||
iolog.start = format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
fs.writeFileSync("iolog.json", JSON.stringify(iolog), "utf-8");
|
||||
iolog.start = new Date();
|
||||
fs.writeFileSync("logs/boot.json", JSON.stringify(iolog), "utf-8");
|
||||
|
||||
// 終了時に終了時刻を保存
|
||||
process.on("exit", () => {
|
||||
const iolog = JSON.parse(fs.readFileSync("iolog.json", "utf-8"));
|
||||
iolog.stop = format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
const iolog = JSON.parse(fs.readFileSync("logs/boot.json", "utf-8"));
|
||||
iolog.stop = new Date();
|
||||
|
||||
fs.writeFileSync("iolog.json", JSON.stringify(iolog), "utf-8");
|
||||
fs.writeFileSync("logs/boot.json", JSON.stringify(iolog), "utf-8");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user