Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2ec6fdc

Browse files
committedApr 28, 2023
exit after loading the agent, launchctl load ... will start the binary
1 parent 5d1f072 commit 2ec6fdc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎config/autostart.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func WritePlistFile() error {
5454
RunAtLoad bool
5555
}{
5656
Program: src,
57-
RunAtLoad: false,
57+
RunAtLoad: true, // This will start the agent right after login (and also after `launchctl load ...`)
5858
}
5959

6060
t := template.Must(template.New("launchdConfig").Parse(string(launchdAgentDefinition)))

‎main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,12 @@ func loop() {
335335
if err != nil {
336336
log.Info(err)
337337
} else {
338-
err = config.LoadLaunchdAgent()
338+
err = config.LoadLaunchdAgent() // this will load the agent: basically starting a new instance
339339
if err != nil {
340340
log.Error(err)
341+
} else {
342+
log.Info("Quitting, another instance of the agent has been started by launchd")
343+
os.Exit(0)
341344
}
342345
}
343346
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.