| 12 | private const string Endpoint = "http://localhost:12346"; |
| 13 | |
| 14 | static void Main() |
| 15 | { |
| 16 | // Configure AppDomain parameter to simplify the config – http://stackoverflow.com/a/3501950/1317575 |
| 17 | AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data")); |
| 18 | |
| 19 | LogProvider.SetCurrentLogProvider(new ColouredConsoleLogProvider()); |
| 20 | |
| 21 | HostFactory.Run(x => |
| 22 | { |
| 23 | x.Service<Application>(s => |
| 24 | { |
| 25 | s.ConstructUsing(name => new Application()); |
| 26 | s.WhenStarted(tc => tc.Start()); |
| 27 | s.WhenStopped(tc => tc.Stop()); |
| 28 | }); |
| 29 | x.RunAsLocalSystem(); |
| 30 | |
| 31 | x.SetDescription("Hangfire Windows Service Sample"); |
| 32 | x.SetDisplayName("Hangfire Windows Service Sample"); |
| 33 | x.SetServiceName("hangfire-sample"); |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | private class Application |
| 38 | { |