Click or drag to resize

KubeServiceRunAsync Method

Starts the service if it's not already running. This will call OnRunAsync, which actually implements the service.

Namespace:  Neon.Kube.Service
Assembly:  Neon.Kube.Service (in Neon.Kube.Service.dll) Version: 2.1.0
Syntax
public virtual Task<int> RunAsync(
	bool disableProcessExit = false
)

Parameters

disableProcessExit (Optional)
Type: SystemBoolean
Optionally specifies that the hosting process should not be terminated when the service exists. This is typically used for testing or debugging. This defaults to false.

Return Value

Type: TaskInt32
The service exit code.
Remarks
Note Note
For production, this method will not return until the service is expicitly stopped via a call to Stop or the Terminator handles a stop signal. For test environments, this method will call OnRunAsync on a new thread and returns immediately while the service continues to run in parallel.

Service implementations must honor Terminator termination signals exiting the OnRunAsync method reasonably quickly (within 30 seconds by default) when these occur. They can do this by passing CancellationToken for async calls and then catching the TaskCanceledException and returning from OnRunAsync.

Another technique for synchronous code is to explicitly check the CancellationToken token's IsCancellationRequested property and return from your OnRunAsync method when this is true. This You'll need to perform this check frequently so you may need to use timeouts to prevent blocking code from blocking for too long.

Remarks
Note Note
It is not possible to restart a service after it's been stopped.
See Also