-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CronExpression not working inside docker #15
Comments
I don’t have any idea about this problem. but thank you for letting me know that. I’m gonna investigate the root cause of the problem. |
did you had time to investigate or need more information? Thank you |
I could not have enough time for the investigation because of my workload. this week, I hope I have enough time for figuring out the problem. |
@peatle-mibt It seems your cron expression you are using is wrong, when I try to schedule a function with the same cron expression, I got an error like saying cron expression must consist of 6 fields. Can you please try to fix your cron expression and try it again? Sorry for late checking the issue. Please also let me know if you have any problem. |
@peatle-mibt your cron expression should be |
It turns out this is not an issue because the cron expression used is wrong. so this issue will be closed. |
I'm sorry, but this was a mistake in the description. it is still not working. From my log when starting: 2022-07-25 08:30:14.921 [INFO] starting reminder service with cron expression */1 * * * * * I don't see any error in the log and i don't see any msg saying that my scheduled method is called. The method called with ScheduleWithFixedDelay is working. As I said, this only happens inside a docker container. |
I also tried to schedule a task with the expression you specified inside docker. It worked for me. Could you give me some code snippets for investigation? I just reopened this issue. |
strange...my code that I tested is: Scheduler := chrono.NewDefaultTaskScheduler()
Scheduler.ScheduleWithCron(func(ctx context.Context) {
log.Info("ping cron")
}, "*/1 * * * * *", chrono.WithLocation("Europe/Berlin"))
Scheduler.ScheduleWithFixedDelay(func(ctx context.Context) {
log.Info("ping delay")
}, time.Duration(5000*int(time.Millisecond))) ping delay gets printed, the other not. in windows and with vscode it works. The OS for docker docker version: |
Hi @peatle-mibt |
Hello. I can confirm that it works without using a location, but with location it isn't. |
Hi, You are using release v1.1.2? |
yes I do. I also tried it within ubuntu 22.04 but no luck, sorry. |
I found the root cause of the problem, it occurs because timezone data is missing in container and it cannot load location info. If you add the following line in your Dockerfile,
It should work as expected. Can you please try this solution? |
thank you!!! that did the trick, so it is an docker/image problem, not with your code. But maybe it would be possible to show some kind of error or warning when location info is not available. |
You’re welcome. Right, it was an issue with Docker image. Actually, when I tried this, schedule function was returning an error saying You can check returned error value after scheduling. |
It turns out this is not an issue with chrono. So this issue will be closed |
I see. that's little weird about golang, errors can be ignored without explicitly doing so. |
CronExpression can be scheduled but never gets executed.
method: ScheduleWithCron(..., ..., chrono.WithLocation("Europe/Berlin"))
expression: does not matter, also */1 * * * * not working
docker-file to build and run:
running the same source outside docker as an executable works.
do you have any ideas?
The text was updated successfully, but these errors were encountered: