topshelf

Topshelf - starting threads based on custom parameters

允我心安 提交于 2019-12-08 02:48:11
问题 I've made a topshelf webservice that uses custom parameter: string department = null; // *********************Below is a TopShelf HostFactory.Run(hostConfigurator => { //Define new parameter hostConfigurator.ApplyCommandLine(); //apply it hostConfigurator.AddCommandLineDefinition("department", f => { department = f; }); Helpers.LogFile("xxx", "Got department:"+department); hostConfigurator.Service<MyService>(serviceConfigurator => { //what service we are using serviceConfigurator

How to pass HostControl instance to custom host service in TopShelf?

社会主义新天地 提交于 2019-12-07 17:14:03
问题 This question has been asked elsewhere on SO, but there is no indication of how I get an instance of a HostControl as the post suggests. My TopShelf main program looks like this: public static void Main() { HostFactory.Run(CreateHost); } private static void CreateHost(HostConfigurator x) { x.UseLog4Net(); x.Service<EventBroker>(s => { s.ConstructUsing(name => new EventBroker()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.StartAutomatically(); x.RunAsNetworkService(

Topshelf timeout issue

别说谁变了你拦得住时间么 提交于 2019-12-07 07:51:21
问题 We are using Topshelf to host a service. Before starting the service, we are making database call to load lot of data. Because of this, while starting the service, we are getting following error: Start Service failed with return code '[7] ServiceRequestTimeout We are using following code to start the service: HostFactory.Run(x => { x.Service<AppService>(s => { s.ConstructUsing(name => new AppService(s_resolver, baseAddress, resolver)); s.WhenStarted(svc => svc.Start()); s.WhenStopped(svc =>

How to pass HostControl instance to custom host service in TopShelf?

懵懂的女人 提交于 2019-12-06 05:07:57
This question has been asked elsewhere on SO , but there is no indication of how I get an instance of a HostControl as the post suggests. My TopShelf main program looks like this: public static void Main() { HostFactory.Run(CreateHost); } private static void CreateHost(HostConfigurator x) { x.UseLog4Net(); x.Service<EventBroker>(s => { s.ConstructUsing(name => new EventBroker()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.StartAutomatically(); x.RunAsNetworkService(); } Any suggestions? Change WhenStarted to have HostControl passed to it like this s.WhenStarted((tc,

Topshelf timeout issue

こ雲淡風輕ζ 提交于 2019-12-05 09:49:28
We are using Topshelf to host a service. Before starting the service, we are making database call to load lot of data. Because of this, while starting the service, we are getting following error: Start Service failed with return code '[7] ServiceRequestTimeout We are using following code to start the service: HostFactory.Run(x => { x.Service<AppService>(s => { s.ConstructUsing(name => new AppService(s_resolver, baseAddress, resolver)); s.WhenStarted(svc => svc.Start()); s.WhenStopped(svc => svc.Stop()); s.WhenShutdown(svc => svc.Shutdown()); }); x.EnableShutdown(); x.RunAsLocalService(); x

Serilog in Windows-Service not writing to logfile

十年热恋 提交于 2019-12-04 22:50:27
I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt". Best regards Gope I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it works like a charm. WriteTo.RollingFile(AppDomain.CurrentDomain.BaseDirectory + "\\logs\\log-{Date}.log") Hope

How can I automate a Topshelf interactive service install?

你。 提交于 2019-12-04 17:59:19
I have a couple Topshelf services that run under a specific service account. If I install the services manually from a command line, I can use the --interactive flag, and a dialog box comes up allowing me to enter the username and password. I'd like to be able to automate this through a Powershell script. Does anyone know how to do this? (Not concerned about Powershell specifically, but with how can I provide the username and password in any installation script.) As Travis mentioned, I took a look at the command line options. Almost working for me, but now I have one escaping issue. To install

CustomAction in Wix not executing

陌路散爱 提交于 2019-12-04 07:26:18
So I'm creating my first Wix project and I seem to be having a problem executing a custom action. I'm not sure that it's being included in the msi and I'm not quite sure what I'm doing wrong. The following is my Wix file: <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/> <MajorUpgrade

How to detect if Topshelf is running in console mode

て烟熏妆下的殇ゞ 提交于 2019-12-04 02:26:13
I am using Topshelf combined with FluentSchedule for a Windows Service. However, I want to be able to trial-run the application to simply start up and not execute the FluentSchedule code that sets up the timer etc. Is there a way when running the exe file from the Command Line (i.e. without 'install' command) to check from TopShelf that it is running in Console mode? Chris Patterson It's sort of a hack, but you can try to cast the HostControl interface to ConsoleRunHost , and if it's that type, you're running as a console application. It's not ideal, sure, but surely you can hide this in an

How to handle async Start() errors in TopShelf

有些话、适合烂在心里 提交于 2019-12-03 13:01:26
问题 I have a TopShelf service that uses async code to connect to web services and other application servers. If it's unable to initialize its connections on startup, the service should log some errors and gracefully stop. I've had a look at this question about stopping TopShelf when the start conditions aren't met. This answer talks about using the TopShelf HostControl to stop the service. However, that answer relies on the ServiceConfigurator<T>.WhenStarted<T>(Func<T, HostControl, bool> start)