service: on darwin add ServiceCreate option.
OS X launchd doesn't create a full session for most services. This may be a performance or security decision. Regardless in order to create a full user session for a service set this option to true. Leaving as false as this is the os and historical default.
This commit is contained in:
+8
-6
@@ -70,12 +70,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
optionKeepAlive = "KeepAlive"
|
optionKeepAlive = "KeepAlive"
|
||||||
optionKeepAliveDefault = true
|
optionKeepAliveDefault = true
|
||||||
optionRunAtLoad = "RunAtLoad"
|
optionRunAtLoad = "RunAtLoad"
|
||||||
optionRunAtLoadDefault = false
|
optionRunAtLoadDefault = false
|
||||||
optionUserService = "UserService"
|
optionUserService = "UserService"
|
||||||
optionUserServiceDefault = false
|
optionUserServiceDefault = false
|
||||||
|
optionSessionCreate = "SessionCreate"
|
||||||
|
optionSessionCreateDefault = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config provides the setup for a Service. The Name field is required.
|
// Config provides the setup for a Service. The Name field is required.
|
||||||
|
|||||||
+8
-5
@@ -5,6 +5,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -13,7 +14,6 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
"errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxPathSize = 32 * 1024
|
const maxPathSize = 32 * 1024
|
||||||
@@ -134,11 +134,13 @@ func (s *darwinLaunchdService) Install() error {
|
|||||||
Path string
|
Path string
|
||||||
|
|
||||||
KeepAlive, RunAtLoad bool
|
KeepAlive, RunAtLoad bool
|
||||||
|
SessionCreate bool
|
||||||
}{
|
}{
|
||||||
Config: s.Config,
|
Config: s.Config,
|
||||||
Path: path,
|
Path: path,
|
||||||
KeepAlive: s.Option.bool(optionKeepAlive, optionKeepAliveDefault),
|
KeepAlive: s.Option.bool(optionKeepAlive, optionKeepAliveDefault),
|
||||||
RunAtLoad: s.Option.bool(optionRunAtLoad, optionRunAtLoadDefault),
|
RunAtLoad: s.Option.bool(optionRunAtLoad, optionRunAtLoadDefault),
|
||||||
|
SessionCreate: s.Option.bool(optionSessionCreate, optionSessionCreateDefault),
|
||||||
}
|
}
|
||||||
|
|
||||||
functions := template.FuncMap{
|
functions := template.FuncMap{
|
||||||
@@ -229,6 +231,7 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
|
|||||||
{{if .UserName}}<key>UserName</key><string>{{html .UserName}}</string>{{end}}
|
{{if .UserName}}<key>UserName</key><string>{{html .UserName}}</string>{{end}}
|
||||||
{{if .ChRoot}}<key>RootDirectory</key><string>{{html .ChRoot}}</string>{{end}}
|
{{if .ChRoot}}<key>RootDirectory</key><string>{{html .ChRoot}}</string>{{end}}
|
||||||
{{if .WorkingDirectory}}<key>WorkingDirectory</key><string>{{html .WorkingDirectory}}</string>{{end}}
|
{{if .WorkingDirectory}}<key>WorkingDirectory</key><string>{{html .WorkingDirectory}}</string>{{end}}
|
||||||
|
<key>SessionCreate</key><{{bool .SessionCreate}}/>
|
||||||
<key>KeepAlive</key><{{bool .KeepAlive}}/>
|
<key>KeepAlive</key><{{bool .KeepAlive}}/>
|
||||||
<key>RunAtLoad</key><{{bool .RunAtLoad}}/>
|
<key>RunAtLoad</key><{{bool .RunAtLoad}}/>
|
||||||
<key>Disabled</key><false/>
|
<key>Disabled</key><false/>
|
||||||
|
|||||||
Reference in New Issue
Block a user