.atran25
.atran25
RRailway
Created by .atran25 on 8/27/2023 in #✋|help
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.
func CharactersIdWeeklyCron() {
// Cron job for adding character ids every Wednesday at 4am PST
cron := gocron.NewScheduler(time.FixedZone("America/Los_Angeles", (-8 * 60 * 60)))
cron.Cron("0 4 * * 3").Do(func() {
dfo.FindCharacterStats()
})
cron.StartAsync()
}

func CharactersStatsDailyCron() {
// Cron job for adding character stats every day at 3am PST
cron := gocron.NewScheduler(time.FixedZone("America/Los_Angeles", (-8 * 60 * 60)))
cron.Cron("*/15 * * * *").Do(func() {
dfo.UpdateCharacterStats()
})
cron.StartAsync()
}
// Setup CRON jobs
if os.Getenv("CRON_ENABLE") == "true" {
l.Info().Msg("Setup CRON jobs")
cron.CharactersIdWeeklyCron()
cron.CharactersStatsDailyCron()
}
func CharactersIdWeeklyCron() {
// Cron job for adding character ids every Wednesday at 4am PST
cron := gocron.NewScheduler(time.FixedZone("America/Los_Angeles", (-8 * 60 * 60)))
cron.Cron("0 4 * * 3").Do(func() {
dfo.FindCharacterStats()
})
cron.StartAsync()
}

func CharactersStatsDailyCron() {
// Cron job for adding character stats every day at 3am PST
cron := gocron.NewScheduler(time.FixedZone("America/Los_Angeles", (-8 * 60 * 60)))
cron.Cron("*/15 * * * *").Do(func() {
dfo.UpdateCharacterStats()
})
cron.StartAsync()
}
// Setup CRON jobs
if os.Getenv("CRON_ENABLE") == "true" {
l.Info().Msg("Setup CRON jobs")
cron.CharactersIdWeeklyCron()
cron.CharactersStatsDailyCron()
}
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?
20 replies