EDMIService: Move service configuration to code
This commit is contained in:
@@ -5,11 +5,12 @@ Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules
|
||||
Imports System.ServiceModel.Description
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports System.ServiceModel.Channels
|
||||
|
||||
Public Class WindowsService
|
||||
Inherits ServiceBase
|
||||
|
||||
Private _ServiceHost As ServiceHost
|
||||
Private _ServiceHost As ServiceHost(Of EDMIService)
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Logger As Logger
|
||||
|
||||
@@ -37,7 +38,7 @@ Public Class WindowsService
|
||||
Try
|
||||
Dim oServicePath As String = AppDomain.CurrentDomain.BaseDirectory
|
||||
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oServicePath)
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, IO.Path.Combine(oServicePath, "Log"))
|
||||
_LogConfig.Debug = True
|
||||
_Logger = _LogConfig.GetLogger()
|
||||
_Logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
|
||||
@@ -79,14 +80,27 @@ Public Class WindowsService
|
||||
EDMIService.Scheduler = _Scheduler
|
||||
|
||||
_Logger.Debug("Starting WCF ServiceHost")
|
||||
_ServiceHost = New ServiceHost(GetType(EDMIService))
|
||||
|
||||
Dim oBaseAddresses() As Uri = {New Uri("net.tcp://localhost:9000/DigitalData/Services/Main")}
|
||||
_ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
|
||||
_ServiceHost.EnableMetadataExchange(False)
|
||||
|
||||
_Logger.Debug("Listing Endpoints:")
|
||||
For Each oEndpoint In _ServiceHost.Description.Endpoints
|
||||
_Logger.Debug("Name: {0}", oEndpoint.Name)
|
||||
_Logger.Debug("Address: {0}", oEndpoint.Address.ToString)
|
||||
_Logger.Debug("Listen Uri: {0}", oEndpoint.ListenUri.AbsoluteUri)
|
||||
_Logger.Debug("Binding: {0}", oEndpoint.Binding.Name)
|
||||
_Logger.Debug("Contract: {0}", oEndpoint.Contract.Name)
|
||||
Next
|
||||
|
||||
_ServiceHost.Open()
|
||||
|
||||
_Logger.Info("WCF ServiceHost started")
|
||||
|
||||
_Logger.Info("Service {0} successfully started", SERVICE_DISPLAY_NAME)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex, "Failed to start the service host!")
|
||||
_Logger.Warn("Unexpected Error while starting the service: {0}", ex.Message)
|
||||
_Logger.Error(ex)
|
||||
GracefullyStop()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user