gottscj/Hangfire.Mongo

Preventing app startup when no Mongo connection avaialble

anth12 opened this issue · 1 comments

If the mongo connection is unavailable, constructing MongoStorage throws an unhandled exception which prevents the application from starting.

StorageOptions.CheckConnection can be disabled to prevent the ping, but migrations still run which require an active connection. Storageoptions.BypassMigration can also be set to true to disable the migrations. However, MongoMigrationManager is internal so it can't be called later when the app has started and the Mongo connection is available.

Are there any recommendations for registering the dependencies & deferring migration until a connection is established?

@anth12,

I see. Could you create a custom MigrationStrategy which executes the migrations when signaled?
You can set the custom strategy in the MongoMigrationOptions
You can edit the set the "MigrationLockTimeout" in the StorageOptions

I will make the migration public and overridable in the next release
Thanks