Hangfire restart

Is it possibile to restart Hangfire and apply new storage config during runtime, without restart entire application?
I need to trap storage connection failure and try new connection to another storage server. I’ve got 3 storage servers.

Maybe the question was not clear, I need to restart only dashboard middleware, can I restart it?

if your tasks are not hosted in the same process that the dashboard, yes but then , your new storage will only be applyed to the dashboard. so it won’t help i guess.

Thank you for your reply,

what I need is to change, at runtime, the RedisStorage used by entire hangfire. I can change Hangfire.JobStorage.Current, but this not affected Dashboard, maybe because dashboard middleware has its own JobStorage object. How can I change JobStorage object, programmatically at runtime, globally in Hangfire?

It doesn’t look like you can.

The JobStorage instance for the dashboard is stored in the the DashboardMiddleware, which is then used in the RequestDispatcherContext. The JobStorage property on the RequestDispatcherContext is also private.

Additionally Owin looks to have no way of removing middleware from a pipeline after configuration, so I think you’d have to tear down the whole Owin host and re-build it.

@nandowalter How did you end up solving your issue? I have a similar requirement, where I need to change dashboard’s job storage at runtime. Curious how you solved it. Thanks.