a year ago
I have deployed a really basic service from github to try out the cron feature. It is supposed to run every 5 minutes and print "Hello World!". I am using the new cron flow with the start command `npm run start` and cron schedule `*/5 * * * *`.
The project is just this: https://github.com/railwayapp-templates/node-cron/tree/main with a different index.ts file:
// src/index.ts
const timeout = setTimeout(() => {
console.error('Job timed out!');
process.exit(1); // Exit with an error code
}, 30000); // 30 seconds timeout
console.log('Hello, World!');
clearTimeout(timeout); // Clear the timeout if the job completes in time
process.exit(0); // Exit normallyThis does run every 5 minutes but the deployment log output seems to vary each time.
Here are the 3 most common deployment outputs/logs I am seeing:
1) Something similar to expected output where my console log does print:
Sep 23 11:15:20 "container event container died
Sep 23 11:15:20 npm warn config production Use --omit=dev instead.
Sep 23 11:15:20 > cron-service@0.1.0 start
Sep 23 11:15:20 > node dist/index.js
Sep 23 11:15:20 Hello, World!"
2) A log saying the container has died
"container event container died"
3) There is no log/output at all
"No deployment logs. All output sent to stdout will be displayed here"
Perhaps I am missing some configuration or just doing it wrong? Any help would be much appreciated.
2 Replies
Status changed to Awaiting User Response Railway • about 1 year ago
4 months ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 4 months ago