a month ago
Hi, i got three instance and any variable you guys provided to define first instance, second instance and third instance? the issue i facing now is, i running cron job in my code but if i got three instance it will run the cron job three time, this is not the things i want. How should i make sure the cron job only run on first instance instaed of three?
8 Replies
a month ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
a month ago
Hi there, can you please share a link to the project you're experiencing issues with, and ideally a screenshot?
Status changed to Awaiting User Response Railway • about 1 month ago
a month ago
you can check the record for this project. at first i use 3 instanace but all my cron job calculation x3, i already change back to 1 instance
Status changed to Awaiting Railway Response Railway • about 1 month ago
a month ago
For your use case, you would want to break out the cron job into its own service.
I will open this thread up to the community so that they can help you with the implementation.
Status changed to Awaiting User Response Railway • about 1 month ago
a month ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • about 1 month ago
a month ago
are you stupid? i put private you simply put public without my concern?
a month ago
fuck you railway
a month ago
If a thread contains no PII and does not require an employee's assistance, we may make the thread public.
https://docs.railway.com/reference/support#private-threads
Status changed to Awaiting User Response Railway • about 1 month ago
a month ago
hey, you can implement this using railway's function method which can automatically run your cron jobs, you can read up on it here
alternatively, you can split your existing service into another worker service with node, looking like:
// worker/index.js
const cron = require('node-cron');
cron.schedule('*/5 * * * *', async () => {
console.log('cron tick');
// do work
});
process.stdin.resume(); // keep process alive if needed
you'd have to assign it a different start command, which can be found here on how to implement
Attachments
Status changed to Awaiting Railway Response Railway • about 1 month ago
Status changed to Solved brody • about 1 month ago