Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd unit to snap packages #4015

Closed
mhalano opened this issue Mar 2, 2017 · 14 comments
Closed

Add systemd unit to snap packages #4015

mhalano opened this issue Mar 2, 2017 · 14 comments
Labels
enhancement New features or improvements of some kind, as opposed to a problem (bug) frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Comments

@mhalano
Copy link

mhalano commented Mar 2, 2017

I tested Syncthing Snap and works great. The only problem is I need to start the service manually with:
$ snap run syncthing
Some Snaps provides a system service. May be this could be a problem with Syncthing which uses a user service instead of a system service on non-Snap packages.
So I think should be a way to start Syncthing Snap-version automatically with a Systemd service.

@calmh
Copy link
Member

calmh commented Mar 20, 2017

It would need to be a user unit like we ship the Debian packages. I don't know enough about neither systemd nor really snaps to judge the best way to do this, so leaving for someone who does.

@calmh calmh added the enhancement New features or improvements of some kind, as opposed to a problem (bug) label Mar 20, 2017
@calmh calmh added this to the Unplanned (Contributions Welcome) milestone Mar 20, 2017
@calmh calmh changed the title Systemd service on Snap Add systemd unit to snap packages Mar 20, 2017
@testbird
Copy link

testbird commented Apr 2, 2017

Yes, IIUC a separate syncthing process will need to run for each user (that is member in the "users" or a "syncthing" group).

I do not know if the network ports are required to be persistent over time and reboots.

For servers including NAS devices (where users are not logged in directly), however, the syncthing processes must be system units. So a configuration option "start permanent server processes for syncthing users" is needed, and the user units should just abort if the system unit mechanism already started processes for the users.

@testbird
Copy link

testbird commented Apr 2, 2017

Ok, port numbers don't seem to be required to be persistent, but it makes very much sense to keep them persistent in system unit configurations, to have the server setup work reliably without separate discovery servers.

@gutierri
Copy link

@calmh @mhalano You do not know much about Snaps Packages, but does this¹ solve it?

[1] https://wiki.archlinux.org/index.php/Snapd

other ref for code http://majorsilence.github.io/Dev/docs/Services/linux-service

@mhalano
Copy link
Author

mhalano commented Apr 16, 2017

@gutierri The second link seems right. The important line is "daemon: simple". Here is the meta data for 'snapweb' snap: https://pastebin.com/88289zj4 and here is the correspondent Systemd unit: https://pastebin.com/ByDHGUa0
Here we have more details: https://snapcraft.io/docs/build-snaps/syntax

@mhalano
Copy link
Author

mhalano commented Nov 25, 2017

Any news about that?

@calmh
Copy link
Member

calmh commented Nov 26, 2017

No-one has submitted a PR for this. So, no.

@calmh calmh removed this from the Unplanned (Contributions Welcome) milestone Feb 11, 2018
@bashfulrobot
Copy link

@calmh Are you looking for a PR on the unit file itself, or the snapcraft.yaml to get the install to put this in?

@calmh
Copy link
Member

calmh commented Apr 13, 2018

Whichever way solves the problem best. As said above, I'm not really the systemd nor snap guy. Our existing unit file is in use in the Debian packages and so on, so it can of course not become snap-specific, if that's even a thing.

@3v1n0
Copy link

3v1n0 commented Jun 15, 2018

Being an user service, there's still no way to support this as we do for system services (as web apps are for examples). Once that support will be there, it will be possible to have this in place (with auto-reload on snap refresh).

See this bug https://bugs.launchpad.net/snappy/+bug/1613420

@josephRice
Copy link

josephRice commented Nov 21, 2018

until this is handled by the snap install. I just grabbed the syncthing@.service file from the syncthing project. Then changed the ExecStart to point to which syncthing on my system instead of /usr/bin/syncthing. In my case it is /snap/bin/syncthing.

syncthing@.service

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target

[Service]
User=%i
ExecStart=/snap/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

[Install]
WantedBy=multi-user.target

I just saved this file in /lib/systemd/system/ (I am using Ubuntu 18.10) on my system. Then ran the following replacing myuser with the correct username

stop any existing syncthing instances running as my user.

$ killall syncthing 

set up systemd user service

$ sudo systemctl enable syncthing@myuser.service
$ sudo systemctl start syncthing@myuser.service

then checked if it started correctly

$ sudo systemctl status syncthing@myuser.service

all is good and it's working.

@jiangytcn
Copy link

hi @josephRice I encountered the same issue, but unfortunately still failed to start syncthing systemd services. syncthing[5546]: need to run as root or suid, my user already had sudo capability, did you changed any permission related to the syncthing snap or user ? thanks

@AudriusButkevicius
Copy link
Member

Please do not pollute issues with support questions.

@AudriusButkevicius
Copy link
Member

Some clarify why this is closed.
We removed support for snaps.
The snap sandboxing seems like a moving target, and we constantly have users complaining it does not work.

@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label May 13, 2021
@syncthing syncthing locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New features or improvements of some kind, as opposed to a problem (bug) frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion
Projects
None yet
Development

No branches or pull requests

10 participants