Skip to content
Browse files

More logging in Host.

  • Loading branch information...
1 parent 8cd1efb commit d4390e9bbfae0cb0d70b26519341d8bb24540063 @jberezanski jberezanski committed Sep 5, 2012
View
4 Rhino.ServiceBus.Host/Actions/DebugAction.cs
@@ -1,9 +1,12 @@
using System;
+using Common.Logging;
namespace Rhino.ServiceBus.Host.Actions
{
public class DebugAction : IAction
{
+ private static readonly ILog Log = LogManager.GetCurrentClassLogger();
+
public void Execute(ExecutingOptions options)
{
var host = new RhinoServiceBusHost();
@@ -31,6 +34,7 @@ public void Execute(ExecutingOptions options)
}
catch (Exception e)
{
+ Log.Fatal("Host has crashed", e);
Console.WriteLine(e);
Console.ReadKey();
}
View
1 Rhino.ServiceBus.Host/Program.cs
@@ -43,6 +43,7 @@ public static int Main(string[] args)
try
{
+ log.Debug("Executing action: " + action);
actions[action].Execute(executingOptions);
return 0;
View
54 Rhino.ServiceBus.Host/RhinoServiceBusHost.cs
@@ -1,7 +1,7 @@
-
-using System;
+using System;
using System.IO;
using System.Reflection;
+using Common.Logging;
namespace Rhino.ServiceBus.Host
{
@@ -10,6 +10,8 @@ namespace Rhino.ServiceBus.Host
internal partial class RhinoServiceBusHost : ServiceBase
{
+ private static readonly ILog Log = LogManager.GetCurrentClassLogger();
+
private RemoteAppDomainHost host;
private string asm;
private string cfg;
@@ -31,24 +33,32 @@ public void SetArguments(ExecutingOptions options)
protected override void OnStart(string[] ignored)
{
- if (string.IsNullOrEmpty(bootStrapper) == false)
- {
- var assembly = LoadAssembly();
- var bootStrapperType = LoadBootStrapperType(assembly);
- host = new RemoteAppDomainHost(bootStrapperType);
- host.Configuration(cfg);
- }
- else
+ try
{
- host = new RemoteAppDomainHost(asm, cfg);
- }
+ if (string.IsNullOrEmpty(bootStrapper) == false)
+ {
+ var assembly = LoadAssembly();
+ var bootStrapperType = LoadBootStrapperType(assembly);
+ host = new RemoteAppDomainHost(bootStrapperType);
+ host.Configuration(cfg);
+ }
+ else
+ {
+ host = new RemoteAppDomainHost(asm, cfg);
+ }
+
+ if (string.IsNullOrEmpty(hostType) == false)
+ {
+ host.SetHostType(hostType);
+ }
- if (string.IsNullOrEmpty(hostType) == false)
+ host.Start();
+ }
+ catch (Exception x)
{
- host.SetHostType(hostType);
+ Log.Fatal("Hosted service failed to start", x);
+ throw;
}
-
- host.Start();
}
private Assembly LoadAssembly()
@@ -77,8 +87,16 @@ private Type LoadBootStrapperType(Assembly assembly)
protected override void OnStop()
{
- if (host != null)
- host.Close();
+ try
+ {
+ if (host != null)
+ host.Close();
+ }
+ catch (Exception x)
+ {
+ Log.Fatal("Hosted service failed to stop", x);
+ throw;
+ }
}
public void DebugStart(string[] arguments)

0 comments on commit d4390e9

Please sign in to comment.
Something went wrong with that request. Please try again.