Monitor a Railway cron service.
One curl at the end of the start command. Three minutes, start to finish.
Before you start
You need a heartbeat in Upglory with its period and grace set to match the service's cron schedule. Its page shows the ping address; put it in a service variable called UPGLORY_PING_URL, so the command stays readable and the URL is not in your repository.
Settings that match this schedule
- Period1 hourThe cron expression on the service, not how long the command takes.
- Grace15 minutesA container has to start before your command does. Leave room for the cold start.
- Channelsemail, TelegramInherited from the workspace default. Change it on this heartbeat if it matters less than the others.
The line
A cron service runs your start command on the schedule and exits. Put the ping at the end of that command, joined with &&, so a non-zero exit sends nothing.
node ./jobs/sync-stock.js && curl -fsS -m 10 --retry 3 "$UPGLORY_PING_URL"
Railway starts a cron service at the scheduled minute and will not start a second one while the first is still running, so a job that overruns its schedule shows up as a miss rather than two runs.
Measure the run time
Ping /start before the job. The ping at the end then records how long it ran, which is how you see a run creeping towards the next one.
curl -fsS -m 10 "$UPGLORY_PING_URL/start"; node ./jobs/sync-stock.js && curl -fsS -m 10 --retry 3 "$UPGLORY_PING_URL"
Report a failure
When the job exits non-zero, say so at once instead of waiting for the grace window to run out.
node ./jobs/sync-stock.js && curl -fsS -m 10 "$UPGLORY_PING_URL" || curl -fsS -m 10 "$UPGLORY_PING_URL/fail"
Test it
Use Send a test ping on the heartbeat's page, or run the curl by hand with the service's variable. Nothing alerts until the first ping arrives, so a job you have not deployed yet never raises an alarm.
What you will see if it stops
Fifteen minutes past the hour, the heartbeat turns down and the alert names the last ping. If the previous run is still going, Railway skipped this one: the run time is what to look at, not the schedule.
last ping 13:01, ran 58 s
Email and Telegram told at 14:15