#Rails rake tasks from a cron job?

24 messages · Page 1 of 1 (latest)

queen bay
#

Should be able to just create another service and run it on an internal using whenever

#

What's the issue?

solid kestrel
#

Maybe my issue is trying to do the cron job on the same service? The other issue I’m having is it’s hard to monitor. It seems to be silently failing and I’m not sure where to look for logs to troubleshoot.

solid kestrel
#

Would you mind explaining what you mean by “run it on an internal”?

queen bay
#

You know, if I knew what I meant yesterday I absolutely would

#

I'd recommend using CMD + K -> New Service, then deploying only the cronjob (using the NIXPACKS_START_CMD variable) to just whatever the cronjob runner start is

solid kestrel
#

Should I deploy the same GitHub project for the cronjob-only service? Or will it somehow have access to my web service?

queen bay
#

Should be able to just deploy the same codebase and set a different start command

simple vector
solid kestrel
#

Is it possible to have my cron job log to the deployed service log? Like can I append to a certain log file and see it on the Railway service logs. Debugging silence is the hardest part.

queen bay
#

I don’t quite understand how it’s “silent”

solid kestrel
#

I’m not sure how to view any logs other than the one that shows in the service dashboard and ‘railway logs’ cli

queen bay
#

Can I have your projectID?

#

You should have 2 services, and each one should be its own log stream

solid kestrel
#

I don’t think cron jobs output anything to the main log though. I’ll grab the project ID when I get back to my computer.

queen bay
#

You should have 2 services, and you should run 1 process per service

solid kestrel
#

OK, here's my projectID 821aa0a3-8233-4cfe-a213-157dc35a48e2. I have a service named cron dedicated to running the scheduled jobs.
I'm still struggling with debugging seemingly silent cron jobs. Wheat I mean by that is if I have a crontab entry

* * * * * /bin/bash -l -c 'echo "Hello, app!"'

"Hello, app" does not appear anywhere in the Railway logs and therefore if that were a rails job instead, I would have no idea if there is an issue with the crontab or if the rails job if failing for some other reason.

#

as far as I can tell, the whenever gem I mentioned previously is working fine. I am seeing a log message [write] crontab file updated which is what I expect the whenever update-crontab command to do, but I have no evidence that the cron service is running or doing anything

austere hawk
#

I'm trying to do this using the whenever gem. I created a new service and tried to set the start command to whenever --update-crontab under Settings > Start Command.

When I hit the check mark, nothing happens, no error messages, but it does not save. Thoughts?

lilac yarrow
#

Hi! I've got this same question. What's the solution in the end?

gilded leaf
lilac yarrow
#

Sorry. What I’m in need of is running cronjobs on a Rails app

queen bay