I can’t get Quantum to work. It does not execute my “cron job”.
I’m using v2.0.0
Below are relevant code bits.
application.ex
def start(_type, _args) do
import Supervisor.Spec, warn: false
# ....
children = [
worker(EbssUtbuSyncer.Scheduler, []),
]
# ....
end
scheduler.ex
defmodule EbssUtbuSyncer.Scheduler do
@moduledoc """
Cronjob like scheduler for this application.
"""
use Quantum.Scheduler,
otp_app: :ebss_utbu_syncer
end
config/prod.ex
config :ebss_utbu_syncer, EbssUtbuSyncer.Scheduler,
jobs: [
# Every day
{"@daily", {EbssUtbuSyncer.Engine, :start}}
]
It does not execute EbssUtbuSyncer.Engine.start.
Yet if I login with --remsh to the application and run EbssUtbuSyncer.Engine.start manualy - all works fine.
I can see (with :observer) that EbssUtbuSyncer.Scheduler is started and has two workers: Runner and Task.Supervisor.
Yes it is and yes I did.
This application is supposed to sync some databases once a month (Engine.start() checks if sync is needed). So it was running for a month+few days before I’ve noticed that Quantum isn’t working.
Since all my tests passes I just configured Quantum, deployed it and forgot
defmodule EbssUtbuSyncer.Application do
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
# Define workers and child supervisors to be supervised
children = [
# Starts a worker by calling: EbssUtbuSyncer.Worker.start_link(arg1, arg2, arg3)
# worker(EbssUtbuSyncer.Worker, [arg1, arg2, arg3]),
supervisor(EbssUtbuSyncer.Repo.Utbu, [], restart: :temporary),
supervisor(EbssUtbuSyncer.Repo.Ebss, [], restart: :temporary),
worker(EbssUtbuSyncer.Scheduler, []),
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: EbssUtbuSyncer.Supervisor]
Supervisor.start_link(children, opts)
end
end
And also I misread parts of your problem… It’s that your task has not been started and not the supervisor… Should have taken more time to read in the busses…
Can you please check if you got any logged errors when you expected your jobs to run or if they failed silently? Or if you get a warning/error when starting the Quantum-Supervisor?
I’m not sure were to look for logs (this is my first elixir project).
I did look into project_dir/var/logs/erlang.log.x (on production machine), but there are no related errors.
Also, when I try to start the application on development machine without MFA tuple - it does not start (gives “no matching function” error). So yeah, quantum gives error when starting Quantum Supervisor with wrong configuration.