From 023092800d19fc1a0bc3b1dc254b3ff55dd42919 Mon Sep 17 00:00:00 2001 From: taichan <40626578+taichanNE30@users.noreply.github.com> Date: Thu, 27 Jul 2023 07:59:25 +0900 Subject: [PATCH 01/15] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST_DISABLEDの説明が古かった --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f5d70c..12945bd 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ pnpm - default "334観測中" ### POST_DISABLED -- 何か値を設定するとMisskeyにノートが投稿されなくなります +- 値を`TRUE`に設定するとMisskeyにノートが投稿されなくなります - 手元で集計のみ行いたい場合等にお使いください ## etc.. From 0daab56470579fae492e968198cbfb7b57265743 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 08:26:01 +0900 Subject: [PATCH 02/15] Update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 12945bd..a84dc77 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ pnpm ## Docker-Composeを用いた構築 この方法ではデータベースも同時に用意可能です ### 公式イメージを用いる場合 +※こちらも参考にしてください( https://github.com/taichanNE30/yamag-docker-compose-example ) 1. 適当なディレクトリを作成します 1. リポジトリ内のenv_templatesを参考に`.env.app`, `.env.db`を作成します 1. 以下のdocker-compose.ymlを作成します From 7bc422e5109f34ce33ad6087a82bcd61f55f80b6 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 09:06:39 +0900 Subject: [PATCH 03/15] Add render.com blueprint --- render.yml | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 render.yml diff --git a/render.yml b/render.yml new file mode 100644 index 0000000..87c6a92 --- /dev/null +++ b/render.yml @@ -0,0 +1,74 @@ +services: + - type: cron + name: yamag-note + runtime: node + schedule: "35 18 * * *" + region: singapole + repo: https://github.com/taichanne30/yamag.git + buildCommand: "bash build-script.sh" + startCommand: "pnpm start" + envVars: + - fromGroup: yamag-settings + - type: cron + name: yamag-remind + runtime: node + schedule: "32 18 * * *" + region: sigapole + repo: https://github.com/taichanne30/yamag.git + buildCommand: "bash build-script.sh" + startCommand: "pnpm start" + envVars: + - fromGroup: yamag-settings + - type: worker + name: yamag-mention + runtime: node + region: sigapole + repo: https://github.com/taichanne30/yamag.git + buildCommand: "bash build-script.sh" + startCommand: "pnpm run mention" + envVars: + - fromGroup: yamag-settings + +databases: + - name: yamag-db + databaseName: yamag + region: singapole + plan: free + +envVarGroups: + - name: yamag-settings + envVars: + - key: DATABASE_URL + fromDatabase: + name: yamag-db + property: connectionString + - key: TZ + value: Asia/Tokyo + sync: false + - key: RECORD_HOUR + value: 3 + sync: false + - key: RECORD_MINUTE + value: 34 + sync: false + - key: MATCHER + value: "(33-?4|:hanshin:)" + sync: false + - key: USER_NAME + value: "334_t" + sync: false + - key: POST_TITLE + value: "Today's 334 Top 10" + sync: false + - key: REMIND_POST_TEXT + value: "334観測中" + sync: false + - key: SERVER_ORIGIN + value: "https://misskey.io" + sync: false + - key: SERVER_TOKEN + value: "some_token_here(必ず設定してね)" + sync: false + - key: POST_DISABLED + value: "FALSE" + sync: false \ No newline at end of file From e532d346d772440afc01e9844e139cbf2f6b194d Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 09:07:52 +0900 Subject: [PATCH 04/15] Fix typo of render.yaml --- render.yml => render.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename render.yml => render.yaml (100%) diff --git a/render.yml b/render.yaml similarity index 100% rename from render.yml rename to render.yaml From 218ec5f05acf6f28f5745f30a3568701ef20fe17 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 09:10:31 +0900 Subject: [PATCH 05/15] Fix blueprint syntax --- render.yaml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/render.yaml b/render.yaml index 87c6a92..a32b75d 100644 --- a/render.yaml +++ b/render.yaml @@ -8,6 +8,10 @@ services: buildCommand: "bash build-script.sh" startCommand: "pnpm start" envVars: + - key: DATABASE_URL + fromDatabase: + name: yamag-db + property: connectionString - fromGroup: yamag-settings - type: cron name: yamag-remind @@ -18,6 +22,10 @@ services: buildCommand: "bash build-script.sh" startCommand: "pnpm start" envVars: + - key: DATABASE_URL + fromDatabase: + name: yamag-db + property: connectionString - fromGroup: yamag-settings - type: worker name: yamag-mention @@ -27,6 +35,10 @@ services: buildCommand: "bash build-script.sh" startCommand: "pnpm run mention" envVars: + - key: DATABASE_URL + fromDatabase: + name: yamag-db + property: connectionString - fromGroup: yamag-settings databases: @@ -38,37 +50,23 @@ databases: envVarGroups: - name: yamag-settings envVars: - - key: DATABASE_URL - fromDatabase: - name: yamag-db - property: connectionString - key: TZ - value: Asia/Tokyo sync: false - key: RECORD_HOUR - value: 3 sync: false - key: RECORD_MINUTE - value: 34 sync: false - key: MATCHER - value: "(33-?4|:hanshin:)" sync: false - key: USER_NAME - value: "334_t" sync: false - key: POST_TITLE - value: "Today's 334 Top 10" sync: false - key: REMIND_POST_TEXT - value: "334観測中" sync: false - key: SERVER_ORIGIN - value: "https://misskey.io" sync: false - key: SERVER_TOKEN - value: "some_token_here(必ず設定してね)" sync: false - key: POST_DISABLED - value: "FALSE" sync: false \ No newline at end of file From e04e657d2c502177da093d5117984e454eccca9d Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 09:12:18 +0900 Subject: [PATCH 06/15] Fix typo --- render.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/render.yaml b/render.yaml index a32b75d..fe032e4 100644 --- a/render.yaml +++ b/render.yaml @@ -17,7 +17,7 @@ services: name: yamag-remind runtime: node schedule: "32 18 * * *" - region: sigapole + region: singapole repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" startCommand: "pnpm start" @@ -30,7 +30,7 @@ services: - type: worker name: yamag-mention runtime: node - region: sigapole + region: singapole repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" startCommand: "pnpm run mention" From 8ff88c62a68e1144989f75111df63aa98e5177cf Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 16:24:10 +0900 Subject: [PATCH 07/15] Set db to allow all ips --- render.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/render.yaml b/render.yaml index fe032e4..c8609dc 100644 --- a/render.yaml +++ b/render.yaml @@ -20,7 +20,7 @@ services: region: singapole repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" - startCommand: "pnpm start" + startCommand: "pnpm run remind" envVars: - key: DATABASE_URL fromDatabase: @@ -46,6 +46,9 @@ databases: databaseName: yamag region: singapole plan: free + ipAllowList: + - source: 0.0.0.0/0 + description: everywhere envVarGroups: - name: yamag-settings From e123522f9f2d71651adac2a756b2640828ab94b7 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 16:29:30 +0900 Subject: [PATCH 08/15] organize --- render.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/render.yaml b/render.yaml index c8609dc..df17aba 100644 --- a/render.yaml +++ b/render.yaml @@ -10,7 +10,7 @@ services: envVars: - key: DATABASE_URL fromDatabase: - name: yamag-db + name: db property: connectionString - fromGroup: yamag-settings - type: cron @@ -22,10 +22,6 @@ services: buildCommand: "bash build-script.sh" startCommand: "pnpm run remind" envVars: - - key: DATABASE_URL - fromDatabase: - name: yamag-db - property: connectionString - fromGroup: yamag-settings - type: worker name: yamag-mention @@ -37,12 +33,12 @@ services: envVars: - key: DATABASE_URL fromDatabase: - name: yamag-db + name: db property: connectionString - fromGroup: yamag-settings databases: - - name: yamag-db + - name: db databaseName: yamag region: singapole plan: free From d64d0d2465f8722129148370f94f8eda296528f5 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 16:33:31 +0900 Subject: [PATCH 09/15] singapore --- render.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/render.yaml b/render.yaml index df17aba..92d2c91 100644 --- a/render.yaml +++ b/render.yaml @@ -3,7 +3,7 @@ services: name: yamag-note runtime: node schedule: "35 18 * * *" - region: singapole + region: singapore repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" startCommand: "pnpm start" @@ -17,7 +17,7 @@ services: name: yamag-remind runtime: node schedule: "32 18 * * *" - region: singapole + region: singapore repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" startCommand: "pnpm run remind" @@ -26,7 +26,7 @@ services: - type: worker name: yamag-mention runtime: node - region: singapole + region: singapore repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" startCommand: "pnpm run mention" @@ -40,7 +40,7 @@ services: databases: - name: db databaseName: yamag - region: singapole + region: singapore plan: free ipAllowList: - source: 0.0.0.0/0 From f6d27d705a144e58312bff2a0f7ddd4cd1c50c37 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 16:47:06 +0900 Subject: [PATCH 10/15] Change db tier --- render.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/render.yaml b/render.yaml index 92d2c91..eec73a1 100644 --- a/render.yaml +++ b/render.yaml @@ -41,7 +41,7 @@ databases: - name: db databaseName: yamag region: singapore - plan: free + plan: starter ipAllowList: - source: 0.0.0.0/0 description: everywhere From 5ee919a355b3fb5a180880c7cd905cbdc772b4ae Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 16:49:52 +0900 Subject: [PATCH 11/15] =?UTF-8?q?=E3=81=AA=E3=81=BE=E3=81=88=E3=82=92?= =?UTF-8?q?=E3=82=8F=E3=81=8B=E3=82=8A=E3=82=84=E3=81=99=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/render.yaml b/render.yaml index eec73a1..249d58f 100644 --- a/render.yaml +++ b/render.yaml @@ -1,6 +1,6 @@ services: - type: cron - name: yamag-note + name: yamag-blueprint-note runtime: node schedule: "35 18 * * *" region: singapore @@ -10,11 +10,11 @@ services: envVars: - key: DATABASE_URL fromDatabase: - name: db + name: yamag-blueprint-db property: connectionString - fromGroup: yamag-settings - type: cron - name: yamag-remind + name: yamag-blueprint-remind runtime: node schedule: "32 18 * * *" region: singapore @@ -24,7 +24,7 @@ services: envVars: - fromGroup: yamag-settings - type: worker - name: yamag-mention + name: yamag-blueprint-mention runtime: node region: singapore repo: https://github.com/taichanne30/yamag.git @@ -33,12 +33,12 @@ services: envVars: - key: DATABASE_URL fromDatabase: - name: db + name: yamag-blueprint-db property: connectionString - fromGroup: yamag-settings databases: - - name: db + - name: yamag-blueprint-db databaseName: yamag region: singapore plan: starter From 7d58f354f35da8c0b923f90aa576ae09d74896fe Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 16:50:59 +0900 Subject: [PATCH 12/15] =?UTF-8?q?=E3=81=AA=E3=81=BE=E3=81=88=E3=82=92?= =?UTF-8?q?=E3=82=8F=E3=81=8B=E3=82=8A=E3=82=84=E3=81=99=E3=81=8F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/render.yaml b/render.yaml index 249d58f..75eb298 100644 --- a/render.yaml +++ b/render.yaml @@ -12,7 +12,7 @@ services: fromDatabase: name: yamag-blueprint-db property: connectionString - - fromGroup: yamag-settings + - fromGroup: yamag-blueprint-settings - type: cron name: yamag-blueprint-remind runtime: node @@ -22,7 +22,7 @@ services: buildCommand: "bash build-script.sh" startCommand: "pnpm run remind" envVars: - - fromGroup: yamag-settings + - fromGroup: yamag-blueprint-settings - type: worker name: yamag-blueprint-mention runtime: node @@ -35,7 +35,7 @@ services: fromDatabase: name: yamag-blueprint-db property: connectionString - - fromGroup: yamag-settings + - fromGroup: yamag-blueprint-settings databases: - name: yamag-blueprint-db @@ -47,7 +47,7 @@ databases: description: everywhere envVarGroups: - - name: yamag-settings + - name: yamag-blueprint-settings envVars: - key: TZ sync: false From 7724c93030b30ce8bb9edefa60d02cad59da7da4 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 17:00:25 +0900 Subject: [PATCH 13/15] Fix command --- render.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/render.yaml b/render.yaml index 75eb298..f4f554c 100644 --- a/render.yaml +++ b/render.yaml @@ -29,7 +29,7 @@ services: region: singapore repo: https://github.com/taichanne30/yamag.git buildCommand: "bash build-script.sh" - startCommand: "pnpm run mention" + startCommand: "pnpm run mentions" envVars: - key: DATABASE_URL fromDatabase: From 24d5a3144ec4a1956435bd7d391e7a4a8ca5e7ff Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Thu, 27 Jul 2023 17:07:57 +0900 Subject: [PATCH 14/15] add render.yml to .dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 57e1bc7..2a6c8e4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,6 +9,7 @@ build-script.sh Dockerfile docker-compose.yml +render.yml node_modules dist From 925df5e677335e785bfb77a1ff2f16acbeaa3ae7 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Fri, 28 Jul 2023 04:51:25 +0900 Subject: [PATCH 15/15] Fix unhandled Error --- src/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index faff2e8..d01e3a9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -147,10 +147,14 @@ const getNotes = async ():Promise> => { ['public', 'home'].includes(note.visibility) && note.user.host === null }) + console.log(`対象のノート: ${filteredNotes.length}件`) let ranking = createRanks(filteredNotes) let text = showRanking(ranking) - let post = await retry(async() => { - YAMAG.Misskey.postNote(text) + console.log("ランキング集計完了\n") + console.log(text) + + await retry(async() => { + return await YAMAG.Misskey.postNote(text) }, { retries: 15, minTimeout: 5000, @@ -158,8 +162,14 @@ const getNotes = async ():Promise> => { console.log(`Retrying: note posting...${num}`) console.debug(err) } + }).then(async n => { + console.log('投稿完了') + }).catch(err => { + console.log("ノート投稿の失敗が既定の回数を超えました") + console.log(err) }) if (Config.isDbEnabled()) { storeRanks(ranking) + console.log('DBに結果を保存しました') } })()