@@ -9,13 +9,10 @@ import (
99 "strconv"
1010 "strings"
1111
12- helpersJSON "github.com/codemodify/systemkit-helpers-conv"
13- helpersExec "github.com/codemodify/systemkit-helpers-os"
14- helpersUser "github.com/codemodify/systemkit-helpers-os"
15- helpersErrors "github.com/codemodify/systemkit-helpers-reflection"
1612 logging "github.com/codemodify/systemkit-logging"
1713 encoders "github.com/codemodify/systemkit-service-encoders-launchd"
1814 spec "github.com/codemodify/systemkit-service-spec"
15+ "github.com/codemodify/systemkit-service/helpers"
1916)
2017
2118var logTag = "LaunchD-SERVICE"
@@ -29,8 +26,8 @@ type launchdService struct {
2926func newServiceFromSERVICE (serviceSpec spec.SERVICE ) Service {
3027 // override some values - platform specific
3128 // https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
32- logDir := filepath .Join (helpersUser .HomeDir ("" ), "Library/Logs" , serviceSpec .Name )
33- if helpersUser .IsRoot () {
29+ logDir := filepath .Join (helpers .HomeDir ("" ), "Library/Logs" , serviceSpec .Name )
30+ if helpers .IsRoot () {
3431 logDir = filepath .Join ("/Library/Logs" , serviceSpec .Name )
3532 }
3633
@@ -42,7 +39,7 @@ func newServiceFromSERVICE(serviceSpec spec.SERVICE) Service {
4239 serviceSpec .Logging .StdErr .Value = filepath .Join (logDir , serviceSpec .Name + ".stderr.log" )
4340 }
4441
45- logging .Debugf ("%s: serviceSpec object: %s" , logTag , helpersJSON .AsJSONString (serviceSpec ))
42+ logging .Debugf ("%s: serviceSpec object: %s" , logTag , helpers .AsJSONString (serviceSpec ))
4643
4744 launchdService := & launchdService {
4845 serviceSpec : serviceSpec ,
@@ -53,8 +50,8 @@ func newServiceFromSERVICE(serviceSpec spec.SERVICE) Service {
5350}
5451
5552func newServiceFromName (name string ) (Service , error ) {
56- serviceFile := filepath .Join (helpersUser .HomeDir ("" ), "Library/LaunchAgents" , name + ".plist" )
57- if helpersUser .IsRoot () {
53+ serviceFile := filepath .Join (helpers .HomeDir ("" ), "Library/LaunchAgents" , name + ".plist" )
54+ if helpers .IsRoot () {
5855 serviceFile = filepath .Join ("/Library/LaunchDaemons" , name + ".plist" )
5956 }
6057
@@ -101,7 +98,7 @@ func (thisRef launchdService) Install() error {
10198func (thisRef launchdService ) Uninstall () error {
10299 // 1.
103100 err := thisRef .Stop ()
104- if err != nil && ! helpersErrors .Is (err , ErrServiceDoesNotExist ) {
101+ if err != nil && ! helpers .Is (err , ErrServiceDoesNotExist ) {
105102 return err
106103 }
107104
@@ -197,21 +194,21 @@ func (thisRef launchdService) Info() Info {
197194}
198195
199196func (thisRef launchdService ) filePath () string {
200- if helpersUser .IsRoot () {
197+ if helpers .IsRoot () {
201198 return filepath .Join ("/Library/LaunchDaemons" , thisRef .serviceSpec .Name + ".plist" )
202199 }
203200
204- return filepath .Join (helpersUser .HomeDir ("" ), "Library/LaunchAgents" , thisRef .serviceSpec .Name + ".plist" )
201+ return filepath .Join (helpers .HomeDir ("" ), "Library/LaunchAgents" , thisRef .serviceSpec .Name + ".plist" )
205202}
206203
207204func runLaunchCtlCommand (args ... string ) (string , error ) {
208- // if !helpersUser .IsRoot() {
205+ // if !helpers .IsRoot() {
209206 // args = append([]string{"--user"}, args...)
210207 // }
211208
212209 logging .Debugf ("%s: RUN-LAUNCHCTL: launchctl %s" , logTag , strings .Join (args , " " ))
213210
214- output , err := helpersExec .ExecWithArgs ("launchctl" , args ... )
211+ output , err := helpers .ExecWithArgs ("launchctl" , args ... )
215212 errAsString := ""
216213 if err != nil {
217214 errAsString = err .Error ()
0 commit comments