public int Run(IServiceStartup startClass, string[] args)
        {
            if (args.Any())
            {
                return(_commandLineApp.Run(args));
            }


            _startUp = new ServiceStartup(startClass);
            _startUp.Initialize();

            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            var handler   = new UnixSignalHandler();

            if (!isWindows)
            {
                handler.WaitForSignal(new System.Collections.Generic.List <Mono.Unix.Native.Signum>
                {
                    Mono.Unix.Native.Signum.SIGQUIT,
                    Mono.Unix.Native.Signum.SIGTERM,
                    Mono.Unix.Native.Signum.SIGHUP
                }, Exit);
            }

            else
            {
                Console.CancelKeyPress += Console_CancelKeyPress;
                Thread.Sleep(Timeout.Infinite);
            }

            return(0);
        }
        public void Execute(Action shutdownServices)
        {
            _shutdownServices = shutdownServices;
            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            var handler   = new UnixSignalHandler();

            if (!isWindows)
            {
                handler.WaitForSignal(new System.Collections.Generic.List <Mono.Unix.Native.Signum>
                {
                    Mono.Unix.Native.Signum.SIGQUIT, // quit signal
                    Mono.Unix.Native.Signum.SIGTERM, // terminate signal
                    Mono.Unix.Native.Signum.SIGHUP   // hangup signal
                }, Exit);
            }
            else
            {
                Console.CancelKeyPress += (sender, args) =>
                {
                    Exit();
                };
                Thread.Sleep(Timeout.Infinite);
            }
        }