Skip to content

Instantly share code, notes, and snippets.

@miketrebilcock
Created July 2, 2013 19:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketrebilcock/5912161 to your computer and use it in GitHub Desktop.
Save miketrebilcock/5912161 to your computer and use it in GitHub Desktop.
Using TopShelf to Host Service Stack
public static void Main(string[] args)
{
var appSettings = new AppSettings();
AppConfig config = new AppConfig(appSettings);
HostFactory.Run(x =>
{
x.UseLog4Net();
x.Service<AppHost>(s =>
{
s.ConstructUsing(name => new AppHost());
s.WhenStarted(ah => { ah.Init(); ah.Start(config.hostname); });
s.WhenStopped(ah => ah.Stop());
});
x.RunAsLocalSystem();
x.SetDescription("My App Description (" + config.appURL + ")");
x.SetDisplayName("My App Name");
x.SetServiceName("MyApp");
x.StartAutomatically();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment