From f037a1cb60c5381a8db85d8f7c676e3fcf4c520a Mon Sep 17 00:00:00 2001 From: ntki72 Date: Wed, 15 Jan 2025 23:01:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=86=E3=83=8A=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=83=A2=E3=83=BC=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/{terms.css => common.css} | 2 +- src/config/env.ts | 2 ++ src/routes/schedule.ts | 6 ++++++ src/services/updateLiveSchedules.ts | 6 ++++++ views/maintenance.ejs | 28 ++++++++++++++++++++++++++++ views/terms.ejs | 4 ++-- 6 files changed, 45 insertions(+), 3 deletions(-) rename public/css/{terms.css => common.css} (98%) create mode 100644 views/maintenance.ejs diff --git a/public/css/terms.css b/public/css/common.css similarity index 98% rename from public/css/terms.css rename to public/css/common.css index f35cd21..ea164b0 100644 --- a/public/css/terms.css +++ b/public/css/common.css @@ -4,7 +4,7 @@ body { padding: 0; } -.terms-container { +.common-container { max-width: 800px; margin: 80px auto; padding: 20px; diff --git a/src/config/env.ts b/src/config/env.ts index 5204bb1..d573fb1 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -16,6 +16,7 @@ const requiredEnvVars = [ "CRON_INTERVAL_MINUTES", "ADMIN_ID", "ADMIN_PASS", + "IS_MAINTENANCE", ]; requiredEnvVars.forEach((varName) => { @@ -37,6 +38,7 @@ export const YOUTUBE_API_KEY = process.env.YOUTUBE_API_KEY as string; export const SESSION_SECRET = process.env.SESSION_SECRET as string; export const ADMIN_ID = process.env.ADMIN_ID as string; export const ADMIN_PASS = process.env.ADMIN_PASS as string; +export const IS_MAINTENANCE = process.env.IS_MAINTENANCE === "true"; // cron のスケジュールを計算 const intervalMinutes = parseInt(process.env.CRON_INTERVAL_MINUTES || "60", 10); diff --git a/src/routes/schedule.ts b/src/routes/schedule.ts index a708a69..0368be0 100644 --- a/src/routes/schedule.ts +++ b/src/routes/schedule.ts @@ -1,3 +1,4 @@ +import { IS_MAINTENANCE } from "../config/env"; import express from "express"; import { LiveSchedule, Channel } from "../models"; import { Op } from "sequelize"; @@ -11,6 +12,11 @@ dayjs.extend(timezone); const router = express.Router(); router.get("/", async (req, res) => { + // IS_MAINTENANCE が true の場合メンテナンスページを表示 + if (IS_MAINTENANCE) { + return res.render("maintenance"); + } + try { const now = dayjs().tz("Asia/Tokyo").startOf("day"); // 当日0時 const liveSchedules = await LiveSchedule.findAll({ diff --git a/src/services/updateLiveSchedules.ts b/src/services/updateLiveSchedules.ts index 8fbebf1..b724e1f 100644 --- a/src/services/updateLiveSchedules.ts +++ b/src/services/updateLiveSchedules.ts @@ -1,7 +1,13 @@ +import { IS_MAINTENANCE } from "../config/env"; import { Channel } from "../models"; import { updateLiveSchedulesForChannel } from "./liveScheduleService"; export const updateAllLiveSchedules = async () => { + if (IS_MAINTENANCE) { + console.log("Maintenance mode is enabled. Skipping live schedule update."); + return; + } + try { const channels = await Channel.findAll(); diff --git a/views/maintenance.ejs b/views/maintenance.ejs new file mode 100644 index 0000000..81d7214 --- /dev/null +++ b/views/maintenance.ejs @@ -0,0 +1,28 @@ + + + + + + + + <%- include("partials/head") %> + + <%- include("partials/header") %> +
+
+
+

メンテナンス中

+
+

+ 現在、サイトはメンテナンス中です。
+ ご不便をおかけして申し訳ございませんが、しばらくお待ちください。 +

+

+ メンテナンスが完了次第、サービスを再開いたします。
+ 何卒ご理解のほどよろしくお願い申し上げます。 +

+
+
+
+ + diff --git a/views/terms.ejs b/views/terms.ejs index cb2e505..26be716 100644 --- a/views/terms.ejs +++ b/views/terms.ejs @@ -3,14 +3,14 @@ - + <%- include("partials/head") %> <%- include("partials/header") %>
-
+

利用規約

サイトの運営について