diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 3e220f9..abf9149 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -16,7 +16,7 @@ }, { "ImportPath": "github.com/kardianos/service", - "Rev": "5ab7ce2c8f38cc0ca92d711f7c4f3ea70d347702" + "Rev": "f53685ef760d69d07e653aba30ffbde7b0a1bcaf" }, { "ImportPath": "github.com/robfig/cron", diff --git a/conf/examples/silver-empty-schema.conf b/conf/examples/silver-empty-schema.conf index f69b6ea..56341bf 100644 --- a/conf/examples/silver-empty-schema.conf +++ b/conf/examples/silver-empty-schema.conf @@ -16,7 +16,7 @@ "Args": ["", ""], "GracefulShutdownTimeout": 5, "RestartDelaySecs": 10, - "MaxCrashCount": 10, + "MaxCrashCountPerHour": 10, "StartupDelaySecs": 20, "MonitorPing": { "URL": "", @@ -31,7 +31,7 @@ "Args": ["", ""], "GracefulShutdownTimeout": 5, "RestartDelaySecs": 10, - "MaxCrashCount": 10, + "MaxCrashCountPerHour": 10, "StartupDelaySecs": 20, "MonitorPing": { "URL": "", diff --git a/conf/examples/silver-kitchen-sink.conf b/conf/examples/silver-kitchen-sink.conf index 409ea92..0a6264a 100644 --- a/conf/examples/silver-kitchen-sink.conf +++ b/conf/examples/silver-kitchen-sink.conf @@ -1,105 +1,105 @@ -{ - "ServiceDescription": { - "DisplayName": "Kitchen Sink Service", - "Description": "This service would do a everything!" - }, - "ServiceConfig": { - "StopFile": ".stop", - "ReloadFile": ".reload", - "LogFile": "${ServiceName}.log", - "LogFileMaxSizeMb": 200, - "PidFile": "${ServiceName}.pid" - }, - "EnvironmentVars": { - "DATA_SOURCE": "localhost:9000" - }, - "Services": [ - { - "Path": "myservice/v*/simple-server", - }, - { - "Path": "myservice/v*/java.exe", - "Args": ["-Xmx=200m", "-Droot=${ServiceRoot}", "org.example.MyServer"], - "GracefulShutdownTimeout": 5, - "RestartDelaySecs": 10, - "MaxCrashCount": 10, - "StartupDelaySecs": 20, - "MonitorPing": { - "URL": "http://localhost:80/login", - "IntervalSecs": 30, - "RestartOnFailureCount": 3, - "TimeoutSecs": 10, - "StartupDelaySecs": 60 - } - }, - { - "Path": "otherservice/v*/service.exe", - "MonitorPing": { - "URL": "echo://127.0.0.1:4300", - "IntervalSecs": 30, - "TimeoutSecs": 10, - "StartupDelaySecs": 30, - "RestartOnFailureCount": 3 - } - }, - { - "Path": "otherservice/v*/service.exe", - "MonitorPing": { - "URL": "echo://127.0.0.1:4300", - "IntervalSecs": 30, - "TimeoutSecs": 10, - "StartupDelaySecs": 30, - "RestartOnFailureCount": 3 - } - }, - { - "Path": "another/v*/service.exe", - "MonitorPing": { - "URL": "file://logs/service.log", - "IntervalSecs": 120, - "RestartOnFailureCount": 1 - } - } - ], - "StartupTasks": [ - { - "Path": "updater.exe", - "Args": ["http://example.org/check-update"], - "TimeoutSecs": 3600, - "StartupDelaySecs": 60, - "StartupRandomDelaySecs": 3600 - }, - { - "Path": "install/verify.exe", - "TimeoutSecs": 10, - "StartupDelaySecs": 0, - "StartupRandomDelaySecs": 1 - } - ], - "ScheduledTasks": [ - { - "Schedule": "@daily", - "Path": "updater.exe", - "Args": ["http://example.org/check-update"], - "StartupRandomDelaySecs": 3600, - "TimeoutSecs": 3600 - }, - { - "Schedule": "0 37 * * * *", - "Path": "cleanup/v*/clean.exe", - "TimeoutSecs": 120 - } - ], - "Commands": [ - { - "Name": "checkupdate", - "Path": "update/v*/checkupdate.exe", - "Args": ["http://example.org/check-update", "-interactive"] - }, - { - "Name": "edit-config", - "Path": "notepad.exe", - "Args": "${ServiceRoot}/config/mysetup.conf" - } - ] -} +{ + "ServiceDescription": { + "DisplayName": "Kitchen Sink Service", + "Description": "This service would do a everything!" + }, + "ServiceConfig": { + "StopFile": ".stop", + "ReloadFile": ".reload", + "LogFile": "${ServiceName}.log", + "LogFileMaxSizeMb": 200, + "PidFile": "${ServiceName}.pid" + }, + "EnvironmentVars": { + "DATA_SOURCE": "localhost:9000" + }, + "Services": [ + { + "Path": "myservice/v*/simple-server", + }, + { + "Path": "myservice/v*/java.exe", + "Args": ["-Xmx=200m", "-Droot=${ServiceRoot}", "org.example.MyServer"], + "GracefulShutdownTimeout": 5, + "RestartDelaySecs": 10, + "MaxCrashCountPerHour": 10, + "StartupDelaySecs": 20, + "MonitorPing": { + "URL": "http://localhost:80/login", + "IntervalSecs": 30, + "RestartOnFailureCount": 3, + "TimeoutSecs": 10, + "StartupDelaySecs": 60 + } + }, + { + "Path": "otherservice/v*/service.exe", + "MonitorPing": { + "URL": "echo://127.0.0.1:4300", + "IntervalSecs": 30, + "TimeoutSecs": 10, + "StartupDelaySecs": 30, + "RestartOnFailureCount": 3 + } + }, + { + "Path": "otherservice/v*/service.exe", + "MonitorPing": { + "URL": "echo://127.0.0.1:4300", + "IntervalSecs": 30, + "TimeoutSecs": 10, + "StartupDelaySecs": 30, + "RestartOnFailureCount": 3 + } + }, + { + "Path": "another/v*/service.exe", + "MonitorPing": { + "URL": "file://logs/service.log", + "IntervalSecs": 120, + "RestartOnFailureCount": 1 + } + } + ], + "StartupTasks": [ + { + "Path": "updater.exe", + "Args": ["http://example.org/check-update"], + "TimeoutSecs": 3600, + "StartupDelaySecs": 60, + "StartupRandomDelaySecs": 3600 + }, + { + "Path": "install/verify.exe", + "TimeoutSecs": 10, + "StartupDelaySecs": 0, + "StartupRandomDelaySecs": 1 + } + ], + "ScheduledTasks": [ + { + "Schedule": "@daily", + "Path": "updater.exe", + "Args": ["http://example.org/check-update"], + "StartupRandomDelaySecs": 3600, + "TimeoutSecs": 3600 + }, + { + "Schedule": "0 37 * * * *", + "Path": "cleanup/v*/clean.exe", + "TimeoutSecs": 120 + } + ], + "Commands": [ + { + "Name": "checkupdate", + "Path": "update/v*/checkupdate.exe", + "Args": ["http://example.org/check-update", "-interactive"] + }, + { + "Name": "edit-config", + "Path": "notepad.exe", + "Args": "${ServiceRoot}/config/mysetup.conf" + } + ] +} diff --git a/make.go b/make.go index f77c4b1..21cceb1 100644 --- a/make.go +++ b/make.go @@ -88,7 +88,7 @@ func main() { func verifyEnv() { if _, err := exec.LookPath("godep"); err != nil { fmt.Println("Please install godep. Run:") - fmt.Println(" go make.go setup") + fmt.Println(" go run make.go setup") } } @@ -96,7 +96,7 @@ func setupEnv() { fmt.Println("Installing godep...") runCmd("go", "get", "github.com/tools/godep") if _, err := exec.LookPath("godep"); err != nil { - fmt.Println("ERROR: godep does note seem to be on the path") + fmt.Println("ERROR: godep does not seem to be on the path") } } diff --git a/service/config/config_test.go b/service/config/config_test.go index cd8f6bf..2710aa5 100644 --- a/service/config/config_test.go +++ b/service/config/config_test.go @@ -23,7 +23,7 @@ func TestLoadConfig_MissingFileShouldRaiseError(t *testing.T) { } } -func TestLocadConfig_ValidConfig(t *testing.T) { +func TestLocalConfig_ValidConfig(t *testing.T) { // Arrange testConfig := ` { @@ -46,7 +46,7 @@ func TestLocadConfig_ValidConfig(t *testing.T) { "Path" : "test/path/1", "Args" : ["arg1", "arg2"], "GracefulShutdownTimeoutSecs" : 12, - "MaxCrashCount" : 999, + "MaxCrashCountPerHour" : 999, "RestartDelaySecs" : 1, "MonitorPing" : { "URL" : "http://localhost:80/login", @@ -144,6 +144,10 @@ func TestLocadConfig_ValidConfig(t *testing.T) { t.Error("Problem extracting arg") } + if c.Services[0].MaxCrashCountPerHour != 999 { + t.Error("MaxCrashCountPerHour field was incorrectly parsed") + } + if c.ScheduledTasks[1].Path != "scheduled/task/2" { t.Error("Problem extracting schedule task path") } @@ -265,7 +269,7 @@ func TestLoadConfig_IncompleteConfig_ShouldError(t *testing.T) { "Path" : "test/path/1", "Args" : ["arg1", "arg2"], "GracefulShutdownTimeoutSecs" : 12, - "MaxCrashCount" : 999, + "MaxCrashCountPerHour" : 999, "RestartDelaySecs" : 1, "MonitorPing" : { "URL" : "http://localhost:80/login",