Service Fabric - how to handle exceptions in startup / WebHostBuilder.Build()

137 views Asked by At

I have a Service Fabric app, if the configuration is incorrect, I get an exception building my web host. For this particularly scenario, the app is never going to start, and Service Fabric is going to continually try to start / provision new app nodes. And when that happens, it becomes difficult to re-deploy the application (sometimes it fails to deploy and sometimes it takes forever)

What's the best way to handle this situation? Catch the exception somewhere so the app starts? Or maybe there is a Service Fabric configuration that specifies how many times it will try to provision / start a new node before it gives up?

1

There are 1 answers

0
LoekD On

When a CodePackage crashes, Service Fabric uses a backoff to start it again. You can modify the restart behavior on the cluster level.

If you change the ActivationRetryBackoffExponentiationBase behavior into 'Exponential' instead of 'Linear', that should give the cluster more quiet time between retries. The value for ActivationMaxFailureCount specifies how many restart attempts should be made.

More info: