We have moved to a new Sailfish OS Forum. Please start new discussions there.
16

Running syncthing permanently in background [answered]

asked 2014-09-05 17:13:14 +0200

Icaruseffect gravatar image

updated 2016-08-16 14:57:11 +0200

jiit gravatar image

After switching from btsync to Syncthing I am using now the systemd approach to keep it running in background as described here in the Syncthing documentation.

The problem now is, that the service gets stopped, when the phone goes into standby. Journalctl -u syncthing delivers this messages:

Jolla systemd[1]: INFO: Paused state detected, possibly woke up from standby
Jolla systemd[1]: INFO: Restarting
Jolla systemd[1]: OK: Exiting
Jolla systemd[1]: syncthing.service: main process exited, code=exited, status=3/NOTIMPLEMENTED
Jolla systemd[1]: Unit syncthing.service entered failed state.

Q: How can I avoid, that the service will be shutdown, even when the phone goes to standby?

My .service file in /etc/systemd/system/multi-user.target.wants/syncthing.service looks now like this:

 [Unit]
Description=Syncthing service
After=network.target

[Service]
User=nemo
Environment=STNORESTART=yes
ExecStart=/usr/bin/syncthing
Restart=always
#Restart=on-success
RestartSec=1min

[Install]
WantedBy=multi-user.target
edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by Icaruseffect
close date 2015-01-03 20:11:21.112167

Comments

You need to keep a wake look active in order to prevent the device to go to deep sleep mode, one option is to use nemo-keepalive library for that: https://github.com/nemomobile/nemo-keepalive

VDVsx ( 2014-09-11 08:52:43 +0200 )edit
1

I think the best solution would be a small Qt app, utilizing this with a timer, depending on ongoing transfers or a time limit. I'm going to look into this, when i find some spare time in the next weeks. Who is interested: the Android Syncthing app (e.g. from F-Droid) works fine together with the systemd service (as far as i tested).

Icaruseffect ( 2014-09-17 12:33:07 +0200 )edit
1

Interestingly Syncthing is about to become Pulse and is being adopted by @aral's IndiePhone project at https://ind.ie/pulse/

Perhaps Jolla and Ind.ie have more in common and could work together?

aegis ( 2014-10-10 00:52:32 +0200 )edit

3 Answers

Sort by » oldest newest most voted
6

answered 2014-11-26 22:48:00 +0200

Icaruseffect gravatar image

Thanks to coderus and how mitakuulu service is being started, i found out how to run syncthing as an user process started by systemd.

Now it is possible to start syncthing by typing (terminal):

devel-su
systemctl --user enable syncthing #permanently enables syncthing
systemctl --user start syncthing #starts syncthing

This way syncthing runs as user process. I now added syncthing as an user process under ~/.config/systemd/user/user-session.target.wants/syncthing.service and the service file looks like this:

   Description=Syncthing
   After=pre-user-session.target

   [Service]
   Type=forking
   Environment=STNORESTART=yes
   ExecStart=/usr/bin/syncthing  
   Restart=always

   [Install]
   WantedBy=user-session.target

You can place the binary also in your home directory, but then changing path after "exec" is needed. The upside is, that auto-upgrading then works without problems. Due to removing the network service dependency it keeps running in background. To save some battery you should increase the directories rescan values.

I hope it helps anyone.

edit flag offensive delete publish link more
4

answered 2015-01-02 20:13:42 +0200

Icaruseffect gravatar image

updated 2015-01-02 20:15:34 +0200

Hi, i have created a script to make the install process easier. You can find it at https://gist.github.com/icaruseffect/4c4fca1f1640f0d01693

You need an activated developer mode and very basic knowledge of the shell to install it. I give you a small walk through how to install it with the provided script:

  1. Collect underpants

  2. activate developer mode and set a password

  3. start the Terminal

  4. type:

    cd Downloads

    git clone https://gist.github.com/4c4fca1f1640f0d01693.git installst

    cd installst

    chmod +x gistfile1.sh

    ./gistfile1.sh

  5. Profit!

edit flag offensive delete publish link more

Comments

thank you very much. I tried but "./gistfile1.sh" doesn't do anything. I don't understand.

Geoffrey Arduini ( 2015-01-04 19:45:46 +0200 )edit
1

Try these instructions (for some reason the link provided by @Icaruseffect doesn't seem to work, even though it is valid):

Start the Terminal and type:

cd Downloads

wget https://gist.githubusercontent.com/plsng/b27ffd967a714aabaaff/raw/48954742b68338f22ddd5a27b21afb6039142888/insync.sh

chmod + x insync.sh

./insync.sh

That should fix it. You can check the link first to see it doesn't contain any malicious code.

nthn ( 2015-01-22 19:38:36 +0200 )edit

I don't get why the question is closed. The fact that it's answered doesn't mean that there'll never be a better answer.

More on-topic; I've done some tweaks to your above script: https://gist.github.com/hobarrera/00ac53fe85a15c1fa414

Do run it, merely:

curl -OL https://gist.github.com/hobarrera/00ac53fe85a15c1fa414/raw/1db7521339cba9dc14690d0d9cefbeea17ead8df/gistfile1.sh
sh gistfile1.sh

The git log describes all the changes in detail.

I'll try to research a bit this weekend on how Sailfish package management works, and see if it's possible to make a proper Sailfish package.

WhyNotHugo ( 2015-05-29 06:19:18 +0200 )edit

you can also use inotify instead of polling directories

https://github.com/syncthing/syncthing-inotify

r0kk3rz ( 2015-10-16 23:44:11 +0200 )edit
3

answered 2014-12-23 19:51:03 +0200

Geoffrey Arduini gravatar image

updated 2014-12-28 16:41:35 +0200

Hello. can you explain how to install Syncthing / Pulse on the Jolla please. I have BTsync via Android but would like a Android Free Sync.

Thank

edit flag offensive delete publish link more

Question tools

Follow
13 followers

Stats

Asked: 2014-09-05 17:13:14 +0200

Seen: 4,317 times

Last updated: Dec 28 '14