@@ -39,7 +39,9 @@ func getLaunchdAgentPath() *paths.Path {
39
39
func InstallPlistFile () {
40
40
launchdAgentPath := getLaunchdAgentPath ()
41
41
if ! launchdAgentPath .Exist () {
42
- writeLoadExit (launchdAgentPath )
42
+ writeAndLoadPlistFile (launchdAgentPath )
43
+ log .Info ("Quitting, another instance of the agent has been started by launchd" )
44
+ os .Exit (0 )
43
45
} else {
44
46
// we already have an existing launchd plist file, so we check if it's updated
45
47
launchAgentContent , _ := launchdAgentPath .ReadFile ()
@@ -49,24 +51,21 @@ func InstallPlistFile() {
49
51
} else {
50
52
log .Infof ("the autostart file %s needs to be updated" , launchdAgentPath )
51
53
removePlistFile ()
52
- writeLoadExit (launchdAgentPath )
54
+ writeAndLoadPlistFile (launchdAgentPath )
53
55
}
54
56
55
57
}
56
58
}
57
59
58
- // writeLoadExit function will write the plist file, load it, and then exit, because launchd will start a new instance.
59
- func writeLoadExit (launchdAgentPath * paths.Path ) {
60
+ // writeAndLoadPlistFile function will write the plist file, load it, and then exit, because launchd will start a new instance.
61
+ func writeAndLoadPlistFile (launchdAgentPath * paths.Path ) {
60
62
err := writePlistFile (launchdAgentPath )
61
63
if err != nil {
62
64
log .Error (err )
63
65
} else {
64
66
err = loadLaunchdAgent () // this will load the agent: basically starting a new instance
65
67
if err != nil {
66
68
log .Error (err )
67
- } else {
68
- log .Info ("Quitting, another instance of the agent has been started by launchd" )
69
- os .Exit (0 )
70
69
}
71
70
}
72
71
}
0 commit comments