Hi! Is it possible to get Sidekiq configuration from Rails side? (the content of config/sidekiq.yml)
Sidekiq.options returns
{
"average_scheduled_poll_interval": 15,
"concurrency": 25,
"dead_max_jobs": 10000,
"dead_timeout_in_seconds": 15552000,
"environment": null,
"error_handlers": [
{}
],
"labels": [],
"lifecycle_events": {
"heartbeat": [],
"quiet": [],
"shutdown": [],
"startup": []
},
"poll_interval_average": null,
"queues": [],
"reloader": {},
"require": ".",
"timeout": 8
}
It differs from config/sidekiq.yml which I think is normal because the config file is read when running sidekiq -C and not rails s
Here the content of config/sidekiq.yml :
:concurrency: 5
:timeout: 15
:queues:
- mailers
- async_mails
- async_imports
- scheduler
:scheduler:
:listened_queues_only: true
It would be nice to have a Sidekiq.config that would return something like :
{
"concurrency": 5,
"queues": [
"mailers",
"async_mails",
"async_imports",
"scheduler"
],
"timeout": 15
}
or better :
{
"sidekiq_worker1": {
"concurrency": 1,
"queues": [
"ssh_exports",
"ftp_exports"
],
"timeout": 15
},
"sidekiq_worker2": {
"concurrency": 25,
"queues": [
"send_mails",
],
"timeout": 15
}
}
in case there would be mutlitple Sidekiq processes (sidekiq -C) running in the same app.
I recognize this is the tricky part since at this point Sidekiq doesn't know about config files until you call sidekiq -C. It largely depends on how people use Sidekiq.
Maybe it could be done by looking for yaml config files in config/sidekiq directory. The hash key would be the file name.
It would be optin for people and would return an empty hash (or fallback to the default file) when no file is found.
What do you think?
Thank you!
opts = YAML.load(ERB.new(IO.read("config/sidekiq.yml")).result)
Most helpful comment