Request: syncthing-inotify

Suggestions for features and software you would like to see in DietPi, goes here.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Request: syncthing-inotify

Post by johnvick »

Got this working now:

/etc/systemd/system/syncthing.service

Code: Select all

[Unit]
Description=Syncthing
After=network.target
Wants=syncthing-inotify@.service

[Service]
Type=oneshot
ExecStart=/bin/bash -c '/usr/bin/syncthing > /var/log/syncthing.log &'
ExecStop=/usr/bin/killall -w syncthing
RemainAfterExit=yes
User=root

[Install]
WantedBy=multi-user.target
/etc/systemd/system/syncthing-inotify@.service

Code: Select all

[Unit]
Description=Syncthing Inotify File Watcher for %I
Documentation=https://github.com/syncthing/syncthing-inotify/blob/master/README.md
After=network.target syncthing@.service
Requires=syncthing@.service

[Service]
User=root
ExecStart=/usr/bin/syncthing-inotify -logflags=0
SuccessExitStatus=2
RestartForceExitStatus=3
Restart=on-failure
ProtectSystem=full
ProtectHome=read-only

[Install]
WantedBy=multi-user.target
Then do:

systemctl enable syncthing-inotify@service

systemctl start syncthing-inotify@service

I got the error about too many files etc so did as suggested here:

https://github.com/syncthing/syncthing- ... s-on-linux

I think this is how I did it but so much trial and error can't be entirely sure. But reboot and in htop I see syncthing-inotify running.

John
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: syncthing-inotify

Post by Fourdee »

johnvick wrote:Got this working now:
Thanks John, great work.

I'll get syncthing-inotify added to the installation of Syncthing by default: https://github.com/Fourdee/DietPi/issues/652
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: Request: syncthing-inotify

Post by Sciamano »

Thanks John for sharing your experience. I have not time to try right now, but please check that syncthing-inotify correctly signals syncthing about file changes.
You can easily do that by modifying one file on the machine with syncthing-inotify, and checking that the other machines receive the modified file immediately (while the "last rescan" time remains the same).
I'm saying this because during my tests, syncthing-inotify was correctly showing in the process list, but it didn't actually do its job properly.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Request: syncthing-inotify

Post by johnvick »

I'm testing this now but just to clarify, if it is working it should sync the files before the syncthing predefined scan interval?

If so it doesn't seem to be working. I've set the interval to 10 minutes and nothing seems to happen.
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: Request: syncthing-inotify

Post by Sciamano »

The purpose of syncthing-inotify is to set a long rescan interval (let's say an hour, for example) to avoid the system to be constantly rescanning the shared folders in search of changed files. Between two rescans syncthing-inotify works by "detecting" file changes and syncing those files almost immediately.
If you modify a file and it's not being immediately "spread" to the other nodes in the syncthing network, then syncthing-inotify isn't working properly.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Request: syncthing-inotify

Post by johnvick »

Ah then it's not working properly. I'll have a look at it again when I get home from holiday.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Request: syncthing-inotify

Post by johnvick »

Decided couldn't wait.

/etc/systemd/system/syncthing-inotify@.service

Code: Select all

[Unit]
Description=Syncthing Inotify File Watcher for %I
Documentation=https://github.com/syncthing/syncthing-inotify/blob/master/README.md
After=network.target syncthing.service
Requires=syncthing.service

[Service]
User=root
ExecStart=/usr/bin/syncthing-inotify -logflags=0
SuccessExitStatus=2
RestartForceExitStatus=3
Restart=on-failure
ProtectSystem=full
ProtectHome=read-only

[Install]
WantedBy=multi-user.target
(Notice this is slightly different from above - now syncthing.service not syncthing@.service)

Then do:

systemctl enable syncthing-inotify@service

systemctl start syncthing-inotify@service

This seems to be working and also working after a reboot - near instantaneous transfer of files despite syncthing being set to rescan the directory every 600 seconds.
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: Request: syncthing-inotify

Post by Sciamano »

That's great John! I'll try it ASAP (which means as soon as this darn flu passes)
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Request: syncthing-inotify

Post by johnvick »

Hi Fourdee,

I see this is now in v140 - can I bring your attention to the post above as I needed to make a minor change to get it working - I hope this made it into v140.

John
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: syncthing-inotify

Post by Fourdee »

johnvick wrote:Hi Fourdee,

I see this is now in v140 - can I bring your attention to the post above as I needed to make a minor change to get it working - I hope this made it into v140.

John
Hi John,

inotify, Yep its in v140. Installed by default with syncthing.

A simple reinstall should do it, pulls in the inotify binaries and service. Backup system 1st with dietpi-backup, just incase.
First remove the service you added:

Code: Select all

/etc/systemd/system/syncthing-inotify@.service
Then reinstall Syncthing:

Code: Select all

dietpi-software reinstall 50
Our service is a little different:

Code: Select all

https://github.com/Fourdee/DietPi/blob/master/dietpi/dietpi-software#L8802-L8817
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Post Reply