Keeping Syncthing Running: Mac OS X (LaunchDaemon)

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.

1 Like

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

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

1 Like

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"?>'

Are you attempting to execute the plist file?

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

1 Like

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
1 Like

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

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

  1. brew update
  2. brew install syncthing
2 Likes

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?

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

1 Like

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.

@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…

@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?

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

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)

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

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.

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

duh. Thanks very much