Dudeman3000
Dudeman3000

Reputation: 601

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

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?

Upvotes: 0

Views: 166

Answers (1)

LoekD
LoekD

Reputation: 11470

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:

Upvotes: 1

Related Questions