Created
July 2, 2013 19:10
-
-
Save miketrebilcock/5912161 to your computer and use it in GitHub Desktop.
Using TopShelf to Host Service Stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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