Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Cron Jobs with Remix
Search
MIZOGUCHI Coji
June 02, 2023
Technology
1
1.1k
Cron Jobs with Remix
Remix でも Cron Job 的なのやりたいですよね!
MIZOGUCHI Coji
June 02, 2023
Tweet
Share
Other Decks in Technology
See All in Technology
New Relic 1 年生の振り返りと Cloud Cost Intelligence について #NRUG
play_inc
0
230
アプリにAIを正しく組み込むための アーキテクチャ── 国産LLMの現実と実践
kohju
0
220
AI駆動開発の実践とその未来
eltociear
2
490
Lookerで実現するセキュアな外部データ提供
zozotech
PRO
0
200
AIBuildersDay_track_A_iidaxs
iidaxs
4
1.3k
AWSに革命を起こすかもしれない新サービス・アップデートについてのお話
yama3133
0
500
Bedrock AgentCore Evaluationsで学ぶLLM as a judge入門
shichijoyuhi
2
240
AWS re:Invent 2025~初参加の成果と学び~
kubomasataka
0
190
Amazon Bedrock Knowledge Bases × メタデータ活用で実現する検証可能な RAG 設計
tomoaki25
6
2.3k
Amazon Quick Suite で始める手軽な AI エージェント
shimy
1
1.8k
普段使ってるClaude Skillsの紹介(by Notebooklm)
zerebom
8
2.1k
AR Guitar: Expanding Guitar Performance from a Live House to Urban Space
ekito_station
0
150
Featured
See All Featured
Done Done
chrislema
186
16k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Building the Perfect Custom Keyboard
takai
1
660
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
0
94
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Unsuck your backbone
ammeep
671
58k
4 Signs Your Business is Dying
shpigford
186
22k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
260
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
38
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
69
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
400
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
310
Transcript
Cron Jobs with Remix COJI Remix Casual Meetup Jun. 1th
2023
Coji Mizoguchi coji techtalkjp coji プログラマー
Remix のアプリで Cron Job したい。 メール送信とかの非同期ジョブ ランキングとか集計とかのバッチジョブ crawler などなど Remix
でも Cron Job 的なのやりたいですよね!
Remix のアプリで Cron Job: どうやって? OS の cron を使う remix
上の一部のコードを共有した別アプリを cron から nodejs で起動? remix 上で api 作って、そこに HTTP で呼ぶ処理を別プロセスで cron から nodejs で起動? これでやるにしても、サーバレスだと OS の cron 使えないの多いし。 微妙! クラウドプラットフォームのジョブスケジューラを使ってAPI をコールさせる サーバレスだと実行時間制限が厳しいですね。 OpenAI とかの処理に時間がかかるようなのをジョブで動かそうとすると厳しい 微妙! remix はモノリシックにできるのが良いのに。 Rails と同じつらみ? なるべく最初は構成もシンプルにしたいですよね
Remix が動いてるのは Nodejs 同一プロセス内で非同期ジョブスケジューラを動かせばいいのでは? サーバ環境は fly.io ( 推し) Remix はカスタムサーバで
シンプルな node-schedule を利用 それぞれ続きのスライドで説明します。 Nodejs は非同期処理が得意。
Remix をカスタムサーバで server.ts express に createRequestHandler でマウントしつつ、同じプロセス内でジョブスケジューラを動かしておく。 import path from
'path' import express from 'express' import { createRequestHandler } from '@remix-run/express' import { createJobSchedular } from 'batch/job-schedular' // ジョブスケジューラ const BUILD_DIR = path.join(process.cwd(), 'build') const port = process.env.PORT || 3000 // express サーバに remix をマウントして起動 const app = express() app.all('*', createRequestHandler({ build: require(BUILD_DIR) })) app.listen(port, () => { require(BUILD_DIR) console.log(`Express server listening on port ${port}`) }) // ジョブスケジューラ。ずっと動かしておく const { start } = createJobSchedular() start()
シンプルな node-schedule を利用 めちゃくちゃシンプルに cron と同じ書き方ができるジョブスケジューラです。 import schedule from 'node-schedule'
import { runTask } from './task' export const createJobSchedular = () => { const start = () => schedule.scheduleJob('10 * * * *', async () => runTask()) // 10 分ごとに起動 return { start } }
その結果 ずっとサーバ代無料で安定してうごいてます!メンテも簡単!
結論 fly.io は良い!( 推し)