Can't make syncthing-inotify properly autostart at boot

Hello, I am running syncthing on an OrangePi PC with DietPi on it. I’ve tried adding syncthing-inotify to this installation, but I can’t seem to make it properly autostart. It runs correctly when I launch it manually, but when I try using the supplied systemd scripts, it does not work (syncthing-inotify runs, but syncthing still rescans the directories constantly). I’ve also tried making it autostart by adding it to the rc.local but to no avail (same behavior). Any help would be appreciated. Thanks!!

Inotify just tells syncthing where to rescan, so rescanning on syncthing is expected to some extent. Check the logs and if they both run as tge same user with the same hoke directory.

Everything is run as root, so there should not be any discrepancy… If I run it manually it works.

It’s not obvious what doesn’t work, atleast to me. syncthing-inotify tells syncthing what to scan, etc, so scanning in the UI is somewhat expect.

I suggest you check the logs for inotify to see if there are any clues.

I can’t seem to find the logs. In /var/log there’s nothing for syncthing-inotify. Am I looking in the wrong place? Thanks

Ok, maybe I have found something:

root@DietRasPi:~# systemctl status -l syncthing-inotify.service
● syncthing-inotify.service - Syncthing Inotify File Watcher
   Loaded: loaded (/etc/systemd/system/syncthing-inotify.service; disabl
ed)
   Active: inactive (dead)
     Docs: https://github.com/syncthing/syncthing-inotify/blob/master/RE
ADME.md
 
Dec 07 09:51:11 DietRasPi syncthing-inotify[1860]: [WARNING] Error: HTTP
 POST forbidden. Missing API key?
Dec 07 09:51:11 DietRasPi syncthing-inotify[1860]: [WARNING] Cannot conn
ect to Syncthing: HTTP POST forbidden
Dec 07 09:51:18 DietRasPi syncthing-inotify[1860]: [WARNING] Error: HTTP
 POST forbidden. Missing API key?
Dec 07 09:51:18 DietRasPi syncthing-inotify[1860]: [WARNING] Cannot conn
ect to Syncthing: HTTP POST forbidden
Dec 07 09:51:34 DietRasPi syncthing-inotify[1860]: [WARNING] Error: HTTP
 POST forbidden. Missing API key?
Dec 07 09:51:34 DietRasPi syncthing-inotify[1860]: [WARNING] Cannot conn
ect to Syncthing: HTTP POST forbidden
Dec 07 09:52:03 DietRasPi syncthing-inotify[1860]: [WARNING] Error: HTTP
 POST forbidden. Missing API key?
Dec 07 09:52:03 DietRasPi syncthing-inotify[1860]: [WARNING] Cannot conn
ect to Syncthing: HTTP POST forbidden
Dec 07 09:52:40 DietRasPi systemd[1]: Stopping Syncthing Inotify File Wa
tcher...
Dec 07 09:52:40 DietRasPi systemd[1]: Stopped Syncthing Inotify File Wat
cher.

Is this helpful?

Inotify can’t look up syncthings config, potentially because systemd does not set $HOME env var.

Ehm… That sounds nice but I don’t understand what it means :smiley: Any hints on how to solve the situation? Thanks

Sadly I am not a systemd expert. According to what guide did you set it all up?

Syncthing is already “bundled” in DietPi. Syncthing-inotify isn’t, so I just downloaded the binary from github. But it only works when run manually. I’m using a work around (set it to run at boot in the crontab) but it’s not the optimal solution, of course… :frowning:

Where did you get systemd filea for inotify?

Also from github, in the etc folder of the syncthing-inotify project.

You should start syncthing-inotify (and syncthing) as a particular user: systemctl enable/start/status syncthing-notify@YOURUSER.service.

Should be the solution. Or bind it to a login session using a user instance:

systemctl --user start ...

Here is some old thread about this user instance thing:

Thanks for the suggestion that I am sure would solve the issue. The problem is that syncthing gets automatically installed and run by user ‘root’ in DietPi, and I have no idea how to change this.

The instructions are for the inotify systemd files oppose to syncthing.

Show me the systemd files from your system; I will explain it.

This should be filed as a bug on DietPi, whatever that is.

Are you sure that it’s set to run as root by default? Or did it just install the systemd files, and you set it to start yourself?

DietPi is a lightweight distribution for development boards like Raspberry Pi, Banana Pi, Odroid and the likes. It has a selection of optimized software that can be installed easily and quickly, and syncthing is one of them. I won’t have access to the board until tomorrow, but as soon as I can I will post the systemd syncthing.service and the two from the syncthing-inotify github, in order to understand what’s wrong. I realize that it would be better if syncthing were run as a normal user, but I guess that even root is a user, and therefore everything should run correctly even if started as root, shouldn’t it?