Skip to content

Commit

Permalink
fix client.login bug (#104)
Browse files Browse the repository at this point in the history
update docker workflow
fix docker-compose to /nfsdocker/nfs
update .dockerignore
  • Loading branch information
im-calvin authored Nov 2, 2023
1 parent b09ef8e commit 3c5aedf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules
.vsode
data
.env
.env.me
.env.me
GOOGLE_APPLICATION_CREDENTIALS.json
googleOAuth2.json
4 changes: 0 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
7 changes: 4 additions & 3 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -18,7 +18,7 @@ export const client = new MittensClient({
],
});

await init();
await monitoringInit();

const boot = Sentry.startTransaction({
op: "boot",
Expand All @@ -29,6 +29,7 @@ const guildTranslateRepo = AppDataSource.getRepository(GuildTranslate);

// on boot
client.once("ready", async () => {
await dbInit();
await scrape();
console.log("もしもし");
});
Expand Down Expand Up @@ -152,7 +153,6 @@ client.on(
oldMessage: Message<boolean> | PartialMessage,
newMessage: Message<boolean> | PartialMessage
) => {

if (oldMessage.partial || newMessage.partial) {
return; // partials are not enabled
}
Expand Down Expand Up @@ -189,4 +189,5 @@ client.on(Events.GuildCreate, (guild) => {
transaction.finish();
});

client.login(readEnv("DISCORD_TOKEN"));
boot.finish();
9 changes: 6 additions & 3 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { client } from "./bot.js";

export const kuroshiro = new Kuroshiro();

export async function init(): Promise<void> {
client.login(readEnv("DISCORD_TOKEN"));
export async function monitoringInit(): Promise<void> {
// inits Sentry
Sentry.init({
dsn: "https://c9c992d5a347411db99537a0ed2c0094@o4505106964742144.ingest.sentry.io/4505106967691264",
Expand All @@ -25,6 +24,11 @@ export async function init(): Promise<void> {
profilesSampleRate: 1.0,
release: "mittens@" + readEnv("npm_package_version"),
});

await kuroshiro.init(new KuromojiAnalyzer());
}

export async function dbInit(): Promise<void> {
// start the db & run migrations
await AppDataSource.initialize();
await AppDataSource.runMigrations();
Expand All @@ -37,5 +41,4 @@ export async function init(): Promise<void> {
for (const video of videos) {
scheduleAnnounce(video.scheduledTime, video, true);
}
await kuroshiro.init(new KuromojiAnalyzer());
}
2 changes: 1 addition & 1 deletion src/utils/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3c5aedf

Please sign in to comment.