diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ed4dfeb..405e2b7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,6 +9,7 @@ updates: # versioning-strategy: increase allow: - dependency-name: "@nestia/*" + - dependency-name: "@nestjs/*" - dependency-name: "nestia" - dependency-name: "tstl" - dependency-name: "typia" diff --git a/package.json b/package.json index f3d53bf..b69d2ea 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "dotenv-expand": "^10.0.0", "git-last-commit": "^1.0.0", "jsonwebtoken": "^9.0.2", - "mutex-server": "^0.3.1", + "mutex-server": "^0.3.2", "prisma": "^5.6.0", "prisma-markdown": "^1.0.7", "source-map-support": "^0.5.19", diff --git a/src/executable/server.ts b/src/executable/server.ts index 2d9b286..2808c1d 100644 --- a/src/executable/server.ts +++ b/src/executable/server.ts @@ -3,9 +3,6 @@ import { randint } from "tstl/algorithm/random"; import { Singleton } from "tstl/thread/Singleton"; import { MyBackend } from "../MyBackend"; -import { MyGlobal } from "../MyGlobal"; -import { MyUpdator } from "../MyUpdator"; -import { MyScheduler } from "../schedulers/MyScheduler"; import { ErrorUtil } from "../utils/ErrorUtil"; const EXTENSION = __filename.substr(-2); @@ -58,15 +55,6 @@ async function main(): Promise { // UNEXPECTED ERRORS global.process.on("uncaughtException", handle_error); global.process.on("unhandledRejection", handle_error); - - // SCHEDULER ONLY WHEN MASTER - if (MyGlobal.env.MODE !== "real" || process.argv[3] === "master") { - if (MyGlobal.env.MODE === "local") - try { - await MyUpdator.master(); - } catch {} - await MyScheduler.repeat(); - } } main().catch((exp) => { console.log(exp); diff --git a/src/schedulers/MyScheduler.ts b/src/schedulers/MyScheduler.ts deleted file mode 100644 index 2576e95..0000000 --- a/src/schedulers/MyScheduler.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { DynamicExecutor } from "@nestia/e2e"; -import mutex from "mutex-server"; -import { sleep_for } from "tstl/thread/global"; - -import { MyGlobal } from "../MyGlobal"; -import { MapUtil } from "../utils/MapUtil"; - -export namespace MyScheduler { - export async function repeat(): Promise { - const critical: mutex.MutexConnector = - await MyGlobal.critical.get(); - const mutex: mutex.RemoteMutex = await critical.getMutex("scheduler"); - await mutex.lock(); - - const dict: Map = new Map(); - await once(dict, Date.now()); - - while (true) { - await sleep_for(INTERVAL); - await once(dict, INTERVAL); - } - } - - async function once( - dict: Map, - interval: number, - ): Promise { - await DynamicExecutor.assert({ - prefix: "schedule", - parameters: (key) => [MapUtil.take(dict)(key, () => interval)], - wrapper: async (key, closure) => { - const slept: number = MapUtil.take(dict)(key, () => interval); - if ((await closure(slept)) === false) dict.set(key, slept + interval); - }, - })(__dirname + "/features"); - } -} - -const INTERVAL = 60_000; diff --git a/src/schedulers/features/schedule_something_in_every_day.ts b/src/schedulers/features/schedule_something_in_every_day.ts deleted file mode 100644 index ca3fb32..0000000 --- a/src/schedulers/features/schedule_something_in_every_day.ts +++ /dev/null @@ -1,9 +0,0 @@ -export async function schedule_something_in_every_day( - interval: number, -): Promise { - if (interval < ONE_DAY) return; - - // DO SOMETHING -} - -const ONE_DAY = 24 * 60 * 60 * 1000; diff --git a/src/schedulers/features/schedule_something_in_every_hour.ts b/src/schedulers/features/schedule_something_in_every_hour.ts deleted file mode 100644 index 3e59f18..0000000 --- a/src/schedulers/features/schedule_something_in_every_hour.ts +++ /dev/null @@ -1,9 +0,0 @@ -export async function schedule_something_in_every_hour( - interval: number, -): Promise { - if (interval < ONE_HOUR) return; - - // DO SOMETHING -} - -const ONE_HOUR = 60 * 60 * 1000; diff --git a/src/schedulers/features/schedule_something_in_every_minutes.ts b/src/schedulers/features/schedule_something_in_every_minutes.ts deleted file mode 100644 index c96c613..0000000 --- a/src/schedulers/features/schedule_something_in_every_minutes.ts +++ /dev/null @@ -1,3 +0,0 @@ -export async function schedule_something_in_every_minutes(): Promise { - // DO SOMETHING -} diff --git a/test/webpack.ts b/test/webpack.ts index eeae716..94f2bd0 100644 --- a/test/webpack.ts +++ b/test/webpack.ts @@ -11,9 +11,10 @@ const webpackTest = async (): Promise => { throw new Error("Run npm run webpack command first."); // START BACKEND SERVER - const backend = cp.fork("server.js", { + const backend = cp.fork(`${MyConfiguration.ROOT}/dist/server.js`, { cwd: `${MyConfiguration.ROOT}/dist`, }); + console.log(__dirname + "/features"); await sleep_for(2_500); // DO TEST diff --git a/webpack.config.js b/webpack.config.js index 5d349b7..101ec22 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -59,10 +59,6 @@ module.exports = { from: "./node_modules/.prisma/client/*.node", to: () => Promise.resolve("[path][name][ext]"), }, - { - from: "./node_modules/ws/**/*.*", - to: () => Promise.resolve("[path][name][ext]"), - }, ], }), new WriteFilePlugin(),