Browse files

Fixed Fake.Deploy crash when service starts after install

  • Loading branch information...
1 parent a276708 commit 3baf3170c35b26fd50aa102134ead9ab1a0fa016 @MorganPersson committed Oct 7, 2012
Showing with 14 additions and 3 deletions.
  1. +8 −2 src/app/Fake.Deploy/Installers.fs
  2. +6 −1 src/app/Fake.Deploy/Services.fs
View
10 src/app/Fake.Deploy/Installers.fs
@@ -5,27 +5,33 @@ open System.Configuration.Install
open System.ServiceProcess
open System.ComponentModel
open System.Reflection
+open System.Diagnostics
+open Fake.Services
+
[<RunInstaller(true)>]
type FakeDeployInstaller() as self =
inherit Installer()
+ let eventLogInstaller = new EventLogInstaller()
let processInstaller = new ServiceProcessInstaller(Account = ServiceAccount.LocalSystem)
let serviceInstaller =
new ServiceInstaller(
DisplayName = "Fake Deploy Service Agent",
Description = "Allows FAKE scripts to run as a deployment",
- ServiceName = "Fake Deploy Agent",
+ ServiceName = ServiceName,
StartType = ServiceStartMode.Automatic
)
do
+ eventLogInstaller.Source <- ServiceName
+ self.Installers.Add eventLogInstaller |> ignore
self.Installers.Add processInstaller |> ignore
self.Installers.Add serviceInstaller |> ignore
override x.OnCommitted(savedState) =
base.OnCommitted(savedState)
- let sc = new ServiceController("Fake Deploy Agent")
+ let sc = new ServiceController(ServiceName)
sc.Start()
View
7 src/app/Fake.Deploy/Services.fs
@@ -6,6 +6,8 @@ open System.Diagnostics
open System.ServiceProcess
open System.Configuration
+let ServiceName = "Fake Deploy Agent"
+
type FakeDeployService() as self =
inherit ServiceBase()
@@ -14,9 +16,12 @@ type FakeDeployService() as self =
let logger =
if Environment.UserInteractive then
TraceHelper.logToConsole
- else
+ else
+ self.EventLog.Log <- "Application"
+ self.EventLog.Source <- ServiceName
self.EventLog.WriteEntry
+
do
self.AutoLog <- true
self.ServiceName <- "Fake Deploy Agent"

0 comments on commit 3baf317

Please sign in to comment.