From 9a30c55e3f15ea76eab5c4c42d9b9b5614437ddb Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Thu, 26 Mar 2015 22:49:40 -0700 Subject: [PATCH] service: add minor docs addition and error messages. --- README.md | 20 +++----------------- service.go | 18 ++++++++++++------ service_upstart_linux.go | 5 ++--- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 7da6597..fbaeec8 100644 --- a/README.md +++ b/README.md @@ -9,20 +9,6 @@ It also can be used to detect how a program is called, from an interactive terminal or from a service manager. ## TODO -Need to test the Interactive test for the following platforms: - * systemd system and user service - * Launchd system and user service - -The following items need to be done: - * Determine if systemd has a launchd equivalent user service. - * Fix Interactive test for user services. - * Document that windows doesn't have a user service. - * Document that upstart's user service definition changes over versions. Do not support. - * For Linux platforms and Launchd add: - - UserName - - Arguments - - WorkingDirectory - - ChRoot - * Determine the best way to document the Config.Option values per platform. - - Should some of the current parameters like "ChRoot" and "WorkingDirectory" move to "Option" map? - + * OS X when running as a UserService Interactive will not be accurate. + * Determine if UserService should remain in main configuration. + * Hook up Dependencies field for Linux systems and Launchd. diff --git a/service.go b/service.go index 3dc99ae..af33822 100644 --- a/service.go +++ b/service.go @@ -75,18 +75,24 @@ type Config struct { DisplayName string // Display name, spaces allowed. Description string // Long description of service. Dependencies []string // Array of service dependencies. - - UserName string // Run as username. - Arguments []string // Run with arguments. + UserName string // Run as username. + Arguments []string // Run with arguments. // Optional field to specify the executable for service. // If empty the current executable is used. - Executable string - WorkingDirectory string // Service working directory. + Executable string + + // The following fields are not supported on Windows. + WorkingDirectory string // Initial working directory. ChRoot string - UserService bool // Install as a current user service. + + // Install as a current user service. Only supported on OS X. + UserService bool // System specific options. + // * OS X + // - KeepAlive bool (true) + // - RunAtLoad bool (false) Option KeyValue } diff --git a/service_upstart_linux.go b/service_upstart_linux.go index 73611ed..63ab325 100644 --- a/service_upstart_linux.go +++ b/service_upstart_linux.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "os" - "os/exec" "os/signal" "text/template" "time" @@ -128,11 +127,11 @@ func (s *upstart) Run() (err error) { } func (s *upstart) Start() error { - return exec.Command("initctl", "start", s.Name).Run() + return run("initctl", "start", s.Name) } func (s *upstart) Stop() error { - return exec.Command("initctl", "stop", s.Name).Run() + return run("initctl", "stop", s.Name) } func (s *upstart) Restart() error {