pruiz / Topshelf.Linux

Topshelf extensions allowing compatibility with mono/linux.
Apache License 2.0
41 stars 14 forks source link

Topshelf.Linux doesn't appear to be working` #1

Closed danbyrne84 closed 7 years ago

danbyrne84 commented 9 years ago

Hi,

I've added the Topshelf.Linux nuget package to my solution and attempting to load my service from the commandline. Is there any further configuration that I need to do, or a particular command line switch?

Error is the same as pre-installation (may not be Topshelf.Linux related...!)

Topshelf v3.1.122.0, .NET Framework v4.0.30319.17020 Default Error: 0 : Unable to get parent process (ignored) System.EntryPointNotFoundException: CreateToolhelp32Snapshot at (wrapper managed-to-native) Topshelf.Runtime.Windows.Kernel32:CreateToolhelp32Snapshot (uint,uint) at Topshelf.Runtime.Windows.WindowsHostEnvironment.GetParent (System.Diagnostics.Process child) [0x00000] in :0 Default Error: 0 : The service terminated abnormally System.NotImplementedException: The requested feature is not implemented. at System.ServiceProcess.UnixServiceController.GetServices () [0x00000] in :0 at System.ServiceProcess.ServiceController.GetServices (System.String machineName) [0x00000] in :0 at System.ServiceProcess.ServiceController.GetServices () [0x00000] in :0 at Topshelf.Runtime.Windows.WindowsHostEnvironment.IsServiceInstalled (System.String serviceName) [0x00000] in :0 at Topshelf.Hosts.ConsoleRunHost.Run () [0x00000] in :0 at Topshelf.HostFactory.Run (System.Action`1 configureCallback) [0x00000] in :0

mgevans commented 9 years ago

Add a call to the UseLinuxIfAvailable extension method on HostConfigurator in your call to HostFactory.Run.

pruiz commented 9 years ago

Sorry, I was a bit missing this past days.. too much TODO latelly has kept me really busy.

Yeah, you should call UseLinuxIfAvailable() during Topself's initialization. Once done, you can start your service using mono-service, or (as always) directly by invoking it on the command line.

On Wed, Aug 6, 2014 at 12:09 AM, mgevans notifications@github.com wrote:

Add a call to the UseLinuxIfAvailable extension method on HostConfigurator in your call to HostFactory.Run.

— Reply to this email directly or view it on GitHub https://github.com/pruiz/Topshelf.Linux/issues/1#issuecomment-51267532.

danbyrne84 commented 9 years ago

Ah great stuff - thankyou

TaridaGeorge commented 7 years ago

So you add Topshelf and Topshelf.Linux libraries with nuget and then define HostFactory.Run method and after that what ? If I start the application from MonoDevelop in debug mode all things are good but what I want to do is to start application in background so If I close the terminal the application would still running. Running the application with mono-service would give me an ouput like this:

mono-service -l:test.lock --no-daemon RDLService.exe -port:27015

Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshelf.HostConfigurationException: The service was not properly configured: [Failure] Command Line An unknown command-line option was found: DEFINE: l = test.lock [Failure] Command Line An unknown command-line option was found: ARGUMENT: RDLService.exe [Success] Name RDLService-Nancy-SelfHost [Success] DisplayName RDLService Nancy-SelfHost Service [Success] Description RDLService Nancy-SelfHost [Success] ServiceName RDLService-Nancy-SelfHost at Topshelf.Configurators.ValidateConfigurationResult.CompileResults (System.Collections.Generic.IEnumerable1[T] results) [0x0002b] in <1c618df2ec3c41f28e50fc16c6be4d5b>:0 at Topshelf.HostFactory.New (System.Action1[T] configureCallback) [0x00052] in <1c618df2ec3c41f28e50fc16c6be4d5b>:0 Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured: [Failure] Command Line An unknown command-line option was found: DEFINE: l = test.lock [Failure] Command Line An unknown command-line option was found: ARGUMENT: RDLService.exe [Success] Name RDLService-Nancy-SelfHost [Success] DisplayName RDLService Nancy-SelfHost Service [Success] Description RDLService Nancy-SelfHost [Success] ServiceName RDLService-Nancy-SelfHost at Topshelf.Configurators.ValidateConfigurationResult.CompileResults (System.Collections.Generic.IEnumerable1[T] results) [0x0002b] in <1c618df2ec3c41f28e50fc16c6be4d5b>:0 at Topshelf.HostFactory.New (System.Action1[T] configureCallback) [0x00052] in <1c618df2ec3c41f28e50fc16c6be4d5b>:0

A wiki page would be great If you are kind.

pruiz commented 7 years ago

@George02 Please, try to append a minimum sample .cs file in order to repro your issue. And maybe open an independent issue here at github.

Regards

pruiz commented 7 years ago

Btw, this is a excerpt code from a Program.cs using Topshelf.Linux:

                         //Start the container
                        using (var container = new WindsorContainer())
                        {
                                var settings = new SettingsAdapter().Create<ISettings>(ConfigurationManager.AppSettings);

                                container.Install(
                                        new Startup.MainInstaller(settings),
                                        new Startup.RebusInstaller(settings),
                                        new Startup.MediatRInstaller()
                                );

                                var service = container.Resolve<DaemonService>();

                                //Start the service
                                HostFactory.Run(x =>
                                {
                                        x.UseNLog();
                                        x.UseLinuxIfAvailable();
                                        x.SetServiceName(ProgramName);
                                        x.SetDescription("Sample Daemon Service");
                                        x.StartAutomatically();
                                        x.RunAsLocalSystem();
                                        x.Service(() => service);
                                });

                                container.Release(service);
                        }