go-cron jobs not running in railway
Hello, so I'm using the go-cron(https://github.com/go-co-op/gocron) library for managing my cron jobs on my Go web server.
https://i.imgur.com/HNMzeif.png
So this is what my cron jobs look like and how I initialize them in my app. The daily job is set to run every 15 minutes just for testing. It runs fine on my local machine, but doesn't seem to run any jobs on railway deployment. It does seem to setup the cron jobs though as can be seen by logs in the screenshot. Would you guys happen to know what could be the reason?
GitHub
GitHub - go-co-op/gocron: Easy and fluent Go cron scheduling. This ...
Easy and fluent Go cron scheduling. This is a fork from https://github.com/jasonlvhit/gocron - GitHub - go-co-op/gocron: Easy and fluent Go cron scheduling. This is a fork from https://github.com/j...
Solution:Jump to solution
I always use UTC on the scheduler because it makes the most sense for server stuff, can you try to initialise each scheduler with UTC?
13 Replies
Project ID:
f9c5389b-b1b9-4d0d-98a7-46d867371f65
f9c5389b-b1b9-4d0d-98a7-46d867371f65
hey I use that package in my projects
Solution
I always use UTC on the scheduler because it makes the most sense for server stuff, can you try to initialise each scheduler with UTC?
gocron.NewScheduler(time.UTC)
Sure, let me try that out right now
Okay yup that fixed it. Thanks for the speedy help!
no problem! did you want to hear my possible solution that would allow you to use time zones?
sure if you have a possible solution I'd love to hear it
import
_ "time/tzdata"
this will embed time zone data into the build
I assume whatever container railway is running your app in is missing the timezone data
and the underscore is very necessaryahh interesting, alright let me try that out
importing the time/tzdata did indeed fix the issue fully
awesome
thanks for all the help!
no problem!