Created
June 15, 2012 04:04
-
-
Save logicbomb/2934619 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using System; | |
| using System.Net; | |
| using System.Threading; | |
| using Lemur.Foundation.Logging; | |
| using Microsoft.WindowsAzure.ServiceRuntime; | |
| using log4net.Config; | |
| namespace LemurMVP.AzureRuntime | |
| { | |
| public class WorkerRoleEntryPoint : RoleEntryPoint, ILoggingSource | |
| { | |
| private AzureServiceHost _host; | |
| public WorkerRoleEntryPoint() | |
| { | |
| NServiceBus.SetLoggingLibrary.Log4Net(XmlConfigurator.Configure); | |
| } | |
| public override bool OnStart() | |
| { | |
| ServicePointManager.DefaultConnectionLimit = 12; | |
| this.WriteDebugMessage("Configuring AzureServiceHost"); | |
| try | |
| { | |
| _host = new AzureServiceHost(); | |
| _host.Configure(); | |
| this.WriteInfoMessage("AzureServiceHost Configured"); | |
| return true; | |
| } | |
| catch (ServiceHostNotConfiguredException e) | |
| { | |
| this.WriteFatalMessage("Could not configure AzureServiceHost", e); | |
| return false; | |
| } | |
| catch (Exception e) | |
| { | |
| this.WriteFatalMessage("Unable to start AzureServiceHost", e); | |
| throw; | |
| } | |
| } | |
| public override void OnStop() | |
| { | |
| _host.Stop(); | |
| this.WriteInfoMessage("AzureServiceHost Stopped"); | |
| } | |
| public override void Run() | |
| { | |
| try | |
| { | |
| _host.Start(); | |
| this.WriteInfoMessage("AzureServiceHost Started"); | |
| Thread.Sleep(Timeout.Infinite); | |
| } | |
| catch (Exception e) | |
| { | |
| this.WriteFatalMessage("An unhandled exception was thrown by the AzureServiceHost", e); | |
| throw; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment