Skip to content

No way to auto-restart Worker Service running as Windows Service on failure #63400

Open
@erikmf12

Description

@erikmf12

Currently when running a worker service as a windows service there is no way to configure the service to restart on failure. Setting Environment.ExitCode = -1 doesn't work. Even if it did, there's no built-in way to tell if a BackgroundService failed expectedly or not unless you try/catch and set the exit code manually (since an exception is thrown away and the host exits with code 0).

Is there a way we can tap into the ServiceBase somehow and set the service to restart on failure? Or at least signal to windows that the exit is not a graceful one?

I need my windows service to be up 24/7 and currently when something fails there's no way to restart it automatically using SCM. Restarting would be fine, but having it fail and requiring a manual start after a period of downtime is unacceptable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions