diff --git a/.dockerignore b/.dockerignore index 3c3a702..513acfd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,6 @@ node_modules .vsode data .env -.env.me \ No newline at end of file +.env.me +GOOGLE_APPLICATION_CREDENTIALS.json +googleOAuth2.json \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cfc532d..2730618 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,7 +23,3 @@ jobs: with: push: true tags: imcalvin/mittens:latest - - name: POST to Portainer - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.PORTAINER_WEBHOOK_URL }} diff --git a/docker-compose.yml b/docker-compose.yml index 9e1c9aa..9e63235 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,6 @@ services: image: imcalvin/mittens:latest restart: always volumes: - - /nfs/mittens/data:/app/data + - /nfsdocker/nfs/mittens/data:/app/data environment: DOTENV_KEY: ${DOTENV_KEY} \ No newline at end of file diff --git a/src/bot.ts b/src/bot.ts index b51d82e..dc3e3ba 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -3,7 +3,7 @@ import MittensClient from "./utils/Client.js"; import { handleTranslate } from "./translate/Translate.js"; import Sentry from "@sentry/node"; import { readEnv } from "./utils/env.js"; -import { init, kuroshiro } from "./init.js"; +import { dbInit, monitoringInit, kuroshiro } from "./init.js"; import { scrape } from "./utils/schedule.js"; import { AppDataSource } from "./db/data-source.js"; import { GuildTranslate } from "./db/entity/GuildTranslate.js"; @@ -18,7 +18,7 @@ export const client = new MittensClient({ ], }); -await init(); +await monitoringInit(); const boot = Sentry.startTransaction({ op: "boot", @@ -29,6 +29,7 @@ const guildTranslateRepo = AppDataSource.getRepository(GuildTranslate); // on boot client.once("ready", async () => { + await dbInit(); await scrape(); console.log("もしもし"); }); @@ -152,7 +153,6 @@ client.on( oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage ) => { - if (oldMessage.partial || newMessage.partial) { return; // partials are not enabled } @@ -189,4 +189,5 @@ client.on(Events.GuildCreate, (guild) => { transaction.finish(); }); +client.login(readEnv("DISCORD_TOKEN")); boot.finish(); diff --git a/src/init.ts b/src/init.ts index 81b9207..1de594b 100644 --- a/src/init.ts +++ b/src/init.ts @@ -11,8 +11,7 @@ import { client } from "./bot.js"; export const kuroshiro = new Kuroshiro(); -export async function init(): Promise { - client.login(readEnv("DISCORD_TOKEN")); +export async function monitoringInit(): Promise { // inits Sentry Sentry.init({ dsn: "https://c9c992d5a347411db99537a0ed2c0094@o4505106964742144.ingest.sentry.io/4505106967691264", @@ -25,6 +24,11 @@ export async function init(): Promise { profilesSampleRate: 1.0, release: "mittens@" + readEnv("npm_package_version"), }); + + await kuroshiro.init(new KuromojiAnalyzer()); +} + +export async function dbInit(): Promise { // start the db & run migrations await AppDataSource.initialize(); await AppDataSource.runMigrations(); @@ -37,5 +41,4 @@ export async function init(): Promise { for (const video of videos) { scheduleAnnounce(video.scheduledTime, video, true); } - await kuroshiro.init(new KuromojiAnalyzer()); } diff --git a/src/utils/schedule.ts b/src/utils/schedule.ts index 4a99686..9680f1e 100644 --- a/src/utils/schedule.ts +++ b/src/utils/schedule.ts @@ -156,7 +156,7 @@ export async function scrape() { } }); - const job = new SimpleIntervalJob({ minutes: intervalTime, runImmediately: false }, task); + const job = new SimpleIntervalJob({ minutes: intervalTime, runImmediately: true }, task); scheduler.addSimpleIntervalJob(job); transaction.finish();