Skip to content

Question: How to use ExitCode? #128

@huseyin-sekmenoglu-covergo

Description

I want to restart the service if service stopped with an error. I found that you have something called exit code: https://github.com/PeterKottas/DotNetCore.WindowsService/blob/4c0052bef2217c3f6b3ec15a98e23335fc07aa88/Source/PeterKottas.DotNetCore.WindowsService/ExitCode.cs

How can I user it in here:

            ServiceRunner<CMailerService>.Run(config =>
            {                
                config.Service(serviceConfig =>
                {                   
                    serviceConfig.OnStop(service =>
                    {

                       //in here I want to restart the service if exitCode!=0
                        _serviceStoppedMail.SendServiceStoppedMail(ProjectConstants.RestartInfoMail, _lastError);


                        Log.Information("Service {0} is stopping...", name);
                        service.Stop();
                        Log.Information("Service {0} stopped", name);
                    });
                });
            });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions