diff --git a/installer/install_windows.go b/installer/install_windows.go index f9017a9..11d7c20 100644 --- a/installer/install_windows.go +++ b/installer/install_windows.go @@ -108,7 +108,7 @@ func installServiceman(c *service.Service) ([]string, error) { // TODO support service level services (which probably wouldn't need serviceman) smdir = filepath.Join(c.Home, ".local", smdir) // for now we'll scope the runner to the name of the application - smbin := filepath.Join(smdir, `bin\serviceman.%s`, c.Name) + smbin := filepath.Join(smdir, `bin\serviceman.`+c.Name) if smbin != self { err := os.MkdirAll(filepath.Dir(smbin), 0755) @@ -130,8 +130,13 @@ func installServiceman(c *service.Service) ([]string, error) { // this should be impossible, so we'll just panic panic(err) } - confpath := filepath.Join(smdir, `etc`, c.Name+`.json`) - err = ioutil.WriteFile(confpath, b, 0640) + confpath := filepath.Join(smdir, `etc`) + err = os.MkdirAll(confpath, 0755) + if nil != err { + return nil, err + } + conffile := filepath.Join(confpath, c.Name+`.json`) + err = ioutil.WriteFile(conffile, b, 0640) if nil != err { return nil, err } @@ -140,7 +145,7 @@ func installServiceman(c *service.Service) ([]string, error) { smbin, "run", "--config", - confpath, + conffile, }, nil } diff --git a/service/service.go b/service/service.go index dbecb11..eb033f0 100644 --- a/service/service.go +++ b/service/service.go @@ -49,26 +49,26 @@ import ( // These are documented as omitted from JSON. // Try to stick to what's outlined above. type Service struct { - Title string `json:"title"` + Title string `json:"title,omitempty"` Name string `json:"name"` - Desc string `json:"desc"` - URL string `json:"url"` - ReverseDNS string `json:"reverse_dns"` // i.e. com.example.foo-app - Interpreter string `json:"interpreter"` // i.e. node, python + Desc string `json:"desc,omitempty"` + URL string `json:"url,omitempty"` + ReverseDNS string `json:"reverse_dns"` // i.e. com.example.foo-app + Interpreter string `json:"interpreter,omitempty"` // i.e. node, python Exec string `json:"exec"` - Argv []string `json:"argv"` - Workdir string `json:"workdir"` - Envs map[string]string `json:"envs"` - User string `json:"user"` - Group string `json:"group"` + Argv []string `json:"argv,omitempty"` + Workdir string `json:"workdir,omitempty"` + Envs map[string]string `json:"envs,omitempty"` + User string `json:"user,omitempty"` + Group string `json:"group,omitempty"` Home string `json:"-"` Local string `json:"-"` Logdir string `json:"logdir"` System bool `json:"system"` Restart bool `json:"restart"` - Production bool `json:"production"` - PrivilegedPorts bool `json:"privileged_ports"` - MultiuserProtection bool `json:"multiuser_protection"` + Production bool `json:"production,omitempty"` + PrivilegedPorts bool `json:"privileged_ports,omitempty"` + MultiuserProtection bool `json:"multiuser_protection,omitempty"` } func (s *Service) Normalize(force bool) { diff --git a/serviceman.go b/serviceman.go index 56b589c..75c2002 100644 --- a/serviceman.go +++ b/serviceman.go @@ -123,7 +123,7 @@ func install() { conf.Normalize(force) - fmt.Printf("\n%#v\n\n", conf) + //fmt.Printf("\n%#v\n\n", conf) err = installer.Install(conf) if nil != err { @@ -179,6 +179,12 @@ func run() { s.Normalize(false) fmt.Fprintf(os.Stdout, "Logdir: %s\n", s.Logdir) + err = os.MkdirAll(s.Logdir, 0755) + if nil != err { + fmt.Fprintf(os.Stderr, "%s\n", err) + return + } + if !daemonize { fmt.Fprintf(os.Stdout, "Running %s %s %s\n", s.Interpreter, s.Exec, strings.Join(s.Argv, " ")) runner.Run(s)