Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hangfire allow just one server

We have an Azure Scale Out resource, the problem is: For each instance, Hangfire launch a new server, any way to limit to one server only?

like image 748
Alexandre Avatar asked Jun 03 '26 14:06

Alexandre


1 Answers

Assuming you are using Sql Server storage, which seems to be the case, you can do:

 GlobalConfiguration.Configuration.UseSqlServerStorage("YourDB");
        var servers = Hangfire.SqlServer.SqlServerStorage.Current
                                                         .GetMonitoringApi()
                                                         .Servers();
        if (servers != null && servers.Count < 1)
            //start new server here;
like image 147
GôTô Avatar answered Jun 06 '26 07:06

GôTô



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!