scratchit

Ubuntu and user systemd startup problem

Recommended Posts

Having problems starting btsync on Ubuntu using user systemd. I need "user" instead of "system" due to permission issues and btsync needs to run as the user syncing the files - saves a lot of headaches. I installed the btsync PPA which creates the systemd files on Ubuntu (actually xubuntu), but after "systemctl --user enable btsync" the btsync process never starts automatically on boot.

I've found a fix for this, at least on Ubuntu, and you need to change the "WantedBy" in /usr/lib/systemd/user/btsync.service as follows:

From:

[Install]
WantedBy=multi-user.target

To

[Install]
WantedBy=default.target

Then reload:

systemctl --user disable btsync
systemctl --user daemon-reload
systemctl --user enable btsync

I don't know if this a bug in btsync or Ubuntu, but this solution works.

Share this post


Link to post
Share on other sites

well, package installed and launched without a problem on my ubuntu 16.06, x64. And it seems that at least 15.04 was already shipped with systemd? 
So how exactly you install the package? Are there any details on how and when it reproduces, a command and its output? Try to purge resilio-sync and install from scratch. 

Share this post


Link to post
Share on other sites

@Helen,

 currently I'm running rslsync manually from the ~/bin folder.  If I install the resilio-sync using apt, how do I make sure the config stays the same?  I am currently redirecting the web gui to a different port and I have it syncing one folder with my android phone.  

Share this post


Link to post
Share on other sites

When I install resilio-sync using apt-get, I see these messages:

Processing triggers for man-db (2.7.5-1) ...
Setting up resilio-sync (2.4.1-1) ...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
insserv: warning: script 'binfmt-support' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `binfmt-support'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `binfmt-support'
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
insserv: warning: script 'screen-cleanup' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `screen-cleanup'
Processing triggers for systemd (229-4ubuntu10) ...

Is this anything to be concerned about?

When I start resilio-sync it fails to start.  

● resilio-sync.service - Resilio Sync service
   Loaded: loaded (/lib/systemd/system/resilio-sync.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Wed 2016-10-05 13:06:42 EDT; 21s ago
     Docs: http://help.getsync.com/
  Process: 1521 ExecStart=/usr/bin/rslsync --config /etc/resilio-sync/config.json (code=exited, status=1/FAILURE)
  Process: 1517 ExecStartPre=/bin/chown -R rslsync:rslsync /var/run/resilio-sync (code=exited, status=0/SUCCESS)
  Process: 1511 ExecStartPre=/bin/mkdir -p /var/run/resilio-sync (code=exited, status=0/SUCCESS)

Oct 05 13:06:42 antonios-linux systemd[1]: Failed to start Resilio Sync service.
Oct 05 13:06:42 antonios-linux systemd[1]: resilio-sync.service: Unit entered failed state.
Oct 05 13:06:42 antonios-linux systemd[1]: resilio-sync.service: Failed with result 'exit-code'.
Oct 05 13:06:42 antonios-linux systemd[1]: resilio-sync.service: Service hold-off time over, scheduling restart.
Oct 05 13:06:42 antonios-linux systemd[1]: Stopped Resilio Sync service.
Oct 05 13:06:42 antonios-linux systemd[1]: resilio-sync.service: Start request repeated too quickly.
Oct 05 13:06:42 antonios-linux systemd[1]: Failed to start Resilio Sync service.
~

I have edited the config file to show as follows:

{
    "storage_path" : "/home/antonios/Music/sync/",
    "pid_file" : "/var/run/resilio-sync/sync.pid",
    "agree_to_EULA": "yes",

    "webui" :
    {
        "listen" : "127.0.0.1:7962"
    }
}

 

Share this post


Link to post
Share on other sites

I have it working now, but I feel there must have been a better way to fix the original problem.

  1. I changed the group on the parent folder to rslsync,
  2. I added user rslsync to group rslsync
  3. I had to delete the synced files on my android device (otherwise a duplicate copy was created)
  4. I relinked the android device to the sync folder 

Here is my current config 

{
    "storage_path" : "/var/lib/resilio-sync/",
    "pid_file" : "/var/run/resilio-sync/sync.pid",
    "agree_to_EULA": "yes",
    "directory_root" : "/home/antonios/Music/sync",
    "directory_root_policy" : "all",

    "webui" :
    {
        "listen" : "127.0.0.1:7962"
    }
}

 

What I have set up is a folder called 'sync' in the Music directory under my home directory on Ubuntu 16.04.  I have the resilio app on my android device.  I want to be able to drop audio files into the 'sync' folder and have them automatically sync to my android device.

This is all working now.  But I basically had to start over from scratch to get it working.  It would have been nice if the android app could have known that  the 'sync' folder that already existed was the folder that I wanted to sync into.  Also the permissions issues on the Ubuntu machine seemed unclear why they were not handled automatically. 

Share this post


Link to post
Share on other sites

@AntoniosHadji The inability to connect to upstart indicate some issues with your Ubuntu. Likely, Sync failed to start later because post-script was not executed and did not changed the ownership os Sync's files.

Share this post


Link to post
Share on other sites

I managed to install the official version on a linux mint 18 desktop (using the current user) without problems. But how do i install resilio-sync on a headless server and make it run as a user (while using systemd?)

 

Share this post


Link to post
Share on other sites

@knireis Pretty much in same way. SSH to your server, and use package manager to get it installed. If you got a systemd on your Linux, see the section "Enable sync service as current user:" in the article - Sync can run as current user.

Share this post


Link to post
Share on other sites

New problem: sync only works when there is a putty connection active to the server, closing the putty connection stops sync. Establishing a putty connection restarts sync.

Anything i can do to have it active all the time without the need to login into the server?

Share this post


Link to post
Share on other sites
On 10/7/2016 at 5:41 PM, knireis said:

systemctl --user enable resilio-sync

without sudo. 

On 10/7/2016 at 8:16 PM, knireis said:

sync only works when there is a putty connection active to the server,

you need to extend the session, try "sudo loginctl enable-linger username" 

Share this post


Link to post
Share on other sites
11 hours ago, Helen said:

without sudo. 

you need to extend the session, try "sudo loginctl enable-linger username" 

Took me a while to figure it out and finally read the answer. Might be useful to put it op on the install page.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.