Chg: 全てのスケジュールが正確に動作するように
This commit is contained in:
+17
-16
@@ -1,25 +1,26 @@
|
||||
import { createUeuse } from "@/lib/client";
|
||||
import initI18n from "@/lib/i18n";
|
||||
import CronExpressionParser from "cron-parser";
|
||||
import { format } from "date-fns";
|
||||
import i18next from "i18next";
|
||||
import { parentPort } from "node:worker_threads";
|
||||
|
||||
await initI18n();
|
||||
|
||||
parentPort?.on("message", async () => {
|
||||
console.log("新年迎春の投稿を行います");
|
||||
const next = BigInt(CronExpressionParser.parse("0 0 1 1 *").next().getTime() * 1_000_000);
|
||||
while (process.hrtime.bigint() > next) {}
|
||||
|
||||
try {
|
||||
await createUeuse({
|
||||
text: i18next.t("hnyNotice", { year: String(new Date().getFullYear()) }),
|
||||
}, "新年迎春");
|
||||
console.log("新年迎春の投稿を行います");
|
||||
|
||||
console.log("新年迎春投稿時刻:", format(new Date(), "yyyy/M/d H:mm:ss:SSS"));
|
||||
process.exit(0);
|
||||
} catch (err: any) {
|
||||
console.error("message" in err
|
||||
? err.message
|
||||
: err);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
try {
|
||||
await createUeuse({
|
||||
text: i18next.t("hnyNotice", { year: String(new Date().getFullYear()) }),
|
||||
}, "新年迎春");
|
||||
|
||||
console.log("新年迎春投稿時刻:", format(new Date(), "yyyy/M/d H:mm:ss:SSS"));
|
||||
process.exit(0);
|
||||
} catch (err: any) {
|
||||
console.error("message" in err
|
||||
? err.message
|
||||
: err);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user