@@ -39,7 +39,7 @@ func getLaunchdAgentPath() *paths.Path {
39
39
func InstallPlistFile () {
40
40
launchdAgentPath := getLaunchdAgentPath ()
41
41
if ! launchdAgentPath .Exist () {
42
- writeLoadExit (launchdAgentPath )
42
+ writeLoadExit (launchdAgentPath , true )
43
43
} else {
44
44
// we already have an existing launchd plist file, so we check if it's updated
45
45
launchAgentContent , _ := launchdAgentPath .ReadFile ()
@@ -49,14 +49,14 @@ func InstallPlistFile() {
49
49
} else {
50
50
log .Infof ("the autostart file %s needs to be updated" , launchdAgentPath )
51
51
removePlistFile ()
52
- writeLoadExit (launchdAgentPath )
52
+ writeLoadExit (launchdAgentPath , false )
53
53
}
54
54
55
55
}
56
56
}
57
57
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 ) {
58
+ // writeLoadExit function will write the plist file, load it, and then exit (if the exit argument is true) , because launchd will start a new instance.
59
+ func writeLoadExit (launchdAgentPath * paths.Path , exit bool ) {
60
60
err := writePlistFile (launchdAgentPath )
61
61
if err != nil {
62
62
log .Error (err )
@@ -65,8 +65,10 @@ func writeLoadExit(launchdAgentPath *paths.Path) {
65
65
if err != nil {
66
66
log .Error (err )
67
67
} else {
68
- log .Info ("Quitting, another instance of the agent has been started by launchd" )
69
- os .Exit (0 )
68
+ if exit {
69
+ log .Info ("Quitting, another instance of the agent has been started by launchd" )
70
+ os .Exit (0 )
71
+ }
70
72
}
71
73
}
72
74
}
0 commit comments