Keeping Syncthing Running: Mac OS X (LaunchDaemon)

(Jakob Borg) #1

Create a file called ~/Library/LaunchAgents/se.nym.syncthing.plist with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
		<key>Label</key>
		<string>se.nym.syncthing</string>
		<key>ProgramArguments</key>
		<array>
			<string>/Users/jb/bin/syncthing</string>
		</array>
		<key>EnvironmentVariables</key>
		<dict>
			<key>HOME</key>
			<string>/Users/jb</string>
			<key>STNORESTART</key>
			<string>1</string>
		</dict>
		<key>KeepAlive</key>
	        <true/>
	</dict>
</plist>

Change the path /Users/jb/bin/syncthing to wherever you have installed the syncthing binary and /Users/jb to your home directory.

The run launchctl load ~/Library/LaunchAgents/se.nym.syncthing.plist and syncthing should be started and kept running in the background.

0 Likes

How to install on OSX?
Syncthing opens a new browser window every time I restart it
no date in mac osx logfile?
(Alexander Kirillov) #2

Recently I added a pull-request to homebrew repository. They have not approved it yet (waiting for a stable version).

0 Likes

(Alexander Kirillov) #3

Until that happens, I put formula in separate repository (homebrew tap). Read README file to install it using homebrew.

1 Like

(Ovizii) #4

I jsut tried this but when I execute it, I get:

sh-3.2# /Library/LaunchAgents/se.nym.syncthing.plist
/Library/LaunchAgents/se.nym.syncthing.plist: line 1: syntax error near unexpected token `newline'
/Library/LaunchAgents/se.nym.syncthing.plist: line 1: `<?xml version="1.0" encoding="UTF-8"?>'
0 Likes

(Jakob Borg) #5

Are you attempting to execute the plist file?

0 Likes

(Ovizii) #6

LOL, I misread this sentence :-/ All good now!

1 Like

(Ovizii) #7

Got a bit of a problem now, in your other reply you explained me how to debug my problem but as soon as I now kill syncthing it restarts immediately so I cannot set the debug options.

Is there a way to edit this file to enter them and have them automatically applied i.e.

STTRACE=model,scanner /Applications/syncthing 2>&1 | tee ~/syncthing.log
0 Likes

Override changes failing
(Jakob Borg) #8

Probably, but easier to just stop the automatic thingy and do it manually.

$ launchctl unload ~/Library/LaunchAgents/se.nym.syncthing.plist
$ STTRACE=model,scanner /Applications/syncthing 2>&1 | tee ~/syncthing.log
...

When done, start it in the background again.

$ launchctl load ~/Library/LaunchAgents/se.nym.syncthing.plist
1 Like

(Alexander Kirillov) #10

Now you can install it from Homebrew officially!!! My pull request was accepted.

  1. brew update
  2. brew install syncthing
2 Likes

(Jakob Borg) #11

That’s awesome! How does this work when a new release is made; is it “automatic” or do you need to make a new pull request etc?

0 Likes

(Alexander Kirillov) #12

I follow for new releases and create new pull requests to update the formula.

1 Like

(wizonesolutions) #13

I tweeted @saratovsource, and he said the Homebrew version looks for configuration in ~/.config/syncthing. I’m not sure where the downloaded version stores configuration, but I’m testing what happens when I simply install with Homebrew.

0 Likes

(Alexander Kirillov) #14

@wizonesolutions sorry. I`m look up in the linux host… look at this https://github.com/syncthing/syncthing/blob/master/cmd/syncthing/main.go#L261 Check ~/.syncthing path too…

0 Likes

(Alexander Kirillov) #15

@wizonesolutions You should find config.xml file in this directory. Please reply if you get some problems… But i think, it should be ok… What old version of Syncthing you have?

0 Likes

(wizonesolutions) #16

@saratovsource 0.9.9. I figured it out, will make separate reply explaining what I did. I got it working :smile:

0 Likes

(wizonesolutions) #17

I was able to get this working in Homebrew by doing the following. I’m not actually sure if I had to do this, but it didn’t cause any problems. Perhaps @saratovsource can correct me if relevant.

As simple as:

pkill syncthing # kill the manually-run daemon from before if relevant

cp -R ~/Library/Application\ Support/Syncthing/ ~/.config/syncthing

rm /usr/local/bin/syncthing # remove symlink if you made one before

brew install syncthing

(and then follow the brew instructions to run it at startup and launch the service)

0 Likes

(Alexander Kirillov) #18

@wizonesolutions I will try at next week with ~/Library/Application\ Support/Syncthing/ directory… Maybe it will work without copy configs ))))

0 Likes

(Seanjh) #19

Is it possible to pass the -no-browser option using this method? Syncthing is generously/annoyingly opening a new web GUI tab every time I wake from sleep. It’s comforting to know the utility is still running, but it’s driving me to madness.

0 Likes

(Jakob Borg) #20

You can just uncheck “Start browser” among the preferences.

0 Likes

(Seanjh) #21

duh. Thanks very much

0 Likes