robfig / cron

a cron library for go
MIT License
13.14k stars 1.63k forks source link

Troubles in docker #499

Closed fulviodenza closed 1 year ago

fulviodenza commented 1 year ago

Hi, I'm running this code which uses robfig/cron v3. I have the following snippet:

// run the goroutine with the cron
go func(ctx context.Context, u *objects.Update) {
[...]
    _, err = b.Scheduler.AddFunc(crontab, func() {
        b.Pill(ctx, u)
    })
[...]

And I'm initializing the scheduler in the following way:

s := cron.New()
s.Start()

Running in debug mode with classic configuration of vs code, the scheduler works fine, while if run it in a docker container with a docker image based on the following file, doesn't work:

FROM golang:1.19.5 as builder

# Create and change to the app directory.
WORKDIR /app
ADD . /app

RUN go build -o /pills

CMD [ "/pills" ]

Logs from the application are not useful since the application runs correctly, just seems to ignore jobs. I don't know if this is a useful information but the app is running in a railway deployment. I've seen there were already some open issues in running jobs in docker containers but they seems to be quite old.