I will enable logging with Log4Net.
The command line is:
> .\ACME.Host.exe install -servicename:Service -instance:01
Except for ACME, this is the code:
using Topshelf;
namespace ACME.Host
{
public static class Hoster
{
public static int Host(IWorker worker)
{
var topshelfExitCode =
HostFactory.Run(
hostConfig =>
{
if (worker.CanPauseAndContinue())
hostConfig.EnablePauseAndContinue();
hostConfig.Service<IWorker>(
serviceConfig =>
{
serviceConfig.ConstructUsing(_ => worker);
serviceConfig.WhenStarted(x => x.Start());
serviceConfig.WhenPaused(x => x.Pause());
serviceConfig.WhenContinued(x => x.Continue());
serviceConfig.WhenStopped(x => x.Stop());
serviceConfig.WhenShutdown(x => x.Stop());
}
);
hostConfig.RunAsPrompt();
}
);
return (int)topshelfExitCode;