Clarify things which confused me my first time trying to set up autostart.

1. For Ubuntu-like systems, I removed the line about clicking to start the
dashboard because it was unnecessarily specific to Unity. There are plenty of
Ubuntu flavors and derivative distros which use other desktops.

2. For the systemd sections about setting up user and system services, I thought
it would make more sense to explain the difference between user- and
system-level services *before* telling the user how to enable them.

3. Pairs of systemd commands where you would run one or the other depending on
how you set up the service should be labeled as such. Otherwise, inexperienced
readers might think you should run the commands in succession.

4. umask is a tricky subject for people who haven't used it before, so I thought
linking to an article that explains it would be helpful.
This commit is contained in:
terrycloth
2015-10-10 23:16:49 -07:00
parent b9c60f6e46
commit 259dd17097
+66 -47
View File
@@ -138,21 +138,20 @@ access the GUI type 127.0.0.1:8384 (by default) into Safari.
Linux Linux
----- -----
Ubuntu like systems On Ubuntu-like systems
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
#. Click the dashboard (hit 'Win' button). #. Launch the program 'Startup Applications'.
#. Open 'Startup Applications'.
#. Click 'Add'. #. Click 'Add'.
#. Fill out the form: #. Fill out the form:
- Name: Syncthing - Name: Syncthing
- ``Command: /path/to/syncthing/binary -no-browser -home="/home/your\_user/.config/syncthing"`` - Command: ``/path/to/syncthing/binary -no-browser -home="/home/your\_user/.config/syncthing"``
Supervisord Using Supervisord
~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Add following to your ``/etc/supervisord.conf``:: Add the following to your ``/etc/supervisord.conf`` file::
[program:syncthing] [program:syncthing]
command = /path/to/syncthing/binary -no-browser -home="/home/some_user/.config/syncthing" command = /path/to/syncthing/binary -no-browser -home="/home/some_user/.config/syncthing"
@@ -161,93 +160,113 @@ Add following to your ``/etc/supervisord.conf``::
user = some_user user = some_user
environment = STNORESTART="1" environment = STNORESTART="1"
systemd Using systemd
~~~~~~~ ~~~~~~~~~~~~~
systemd is a suite of system management daemons, libraries, and systemd is a suite of system management daemons, libraries, and
utilities designed as a central management and configuration platform utilities designed as a central management and configuration platform
for the Linux computer operating system. It also offers users the for the Linux computer operating system. It also offers users the
ability to manage services under the user's control with a per-user ability to manage services under the user's control with a per-user
systemd instance, enabling users to start, stop, enable, and disable systemd instance, enabling users to start, stop, enable, and disable
their own units. Service files for system are provided by Syncthing and their own units. Service files for systemd are provided by Syncthing and
can be found in can be found in
`etc/linux-systemd <https://github.com/syncthing/syncthing/tree/master/etc/linux-systemd>`_. `etc/linux-systemd <https://github.com/syncthing/syncthing/tree/master/etc/linux-systemd>`_.
Several distros (including arch linux) ship these service files with the
Syncthing package. If your distro provides a systemd service file for
Syncthing you can skip step 2.
How to use the system instance You have two primary options: You can set up Syncthing as a system service, or a
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ user service.
Running Syncthing as a system service ensures that Syncthing is run at startup Running Syncthing as a system service ensures that Syncthing is run at startup
even if the Syncthing user has no active session. Since the system service even if the Syncthing user has no active session. Since the system service keeps
keeps Syncthing running even without an active user session, it is intended to Syncthing running even without an active user session, it is intended to be used
be used on a *server*. on a *server*.
#. Create the user who should run the service, or choose an existing Running Syncthing as a user service ensures that Syncthing only starts after the
one. user has logged into the sytem (e.g., via the graphical login screen, or ssh).
#. Copy the ``system/syncthing@.service`` file into the `load path of Thus, the user service is intended to be used on a *(multiuser) desktop
the system computer*. It avoids unnecessarily running Syncthing instances.
instance <http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20Load%20Path>`__.
#. Enable and start the service. Append the Syncthing user after the Several distros (including arch linux) ship the needed service files with the
``@``:: Syncthing package. If your distro provides a systemd service file for Syncthing,
you can skip step 2 when you setting up either the system service or the user
service, as described below.
How to set up a system service
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#. Create the user who should run the service, or choose an existing one.
#. Copy the ``Syncthing/etc/system/syncthing@.service`` file into the
`load path of the system instance
<http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20Load%20Path>`__.
#. Enable and start the service. Replace "myuser" with the actual Syncthing
user after the ``@``::
systemctl enable syncthing@myuser.service systemctl enable syncthing@myuser.service
systemctl start syncthing@myuser.service systemctl start syncthing@myuser.service
How to use the user instance How to set up a user service
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Running Syncthing as a user service ensures that Syncthing is run after the
Syncthing user has created a session (e.g. via the graphical login screen or
ssh). Thus, the user service is intended to be used on a *(multiuser) desktop
computer*. It avoids unnecessarily running Syncthing instances.
#. Create the user who should run the service, or choose an existing #. Create the user who should run the service, or choose an existing
one. one. *Probably this will be your own user account.*
#. Copy the ``user/syncthing.service`` file into the `load path of the #. Copy the ``Syncthing/etc/user/syncthing.service`` file into the `load path
user of the user instance
instance <http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20Load%20Path>`__. <http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20Load%20Path>`__.
To do this without root privileges you can use To do this without root privileges you can just use this folder under your
``~/.config/systemd/user/``. home directory: ``~/.config/systemd/user/``.
#. Enable and start the service:: #. Enable and start the service::
systemctl --user enable syncthing.service systemctl --user enable syncthing.service
systemctl --user start syncthing.service systemctl --user start syncthing.service
Checking the service status
^^^^^^^^^^^^^^^^^^^^^^^^^^^
To check if Syncthing runs properly you can use the ``status`` To check if Syncthing runs properly you can use the ``status``
subcommand:: subcommand. To check the status of a system service::
systemctl status syncthing@myuser.service systemctl status syncthing@myuser.service
To check the status of a user service::
systemctl --user status syncthing.service systemctl --user status syncthing.service
Using the journal Using the journal
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
Systemd logs everything into the journal. You can easily access Syncthing Systemd logs everything into the journal, so you can easily access Syncthing log
log messages (``-e`` lets the pager jump to the very end):: messages. In both of the following examples, ``-e`` tells the pager to jump to
the very end, so that you see the most recent logs.
To see the logs for the system service::
journalctl -e -u syncthing@myuser.service journalctl -e -u syncthing@myuser.service
To see the logs for the user service::
journalctl -e --user-unit=syncthing.service journalctl -e --user-unit=syncthing.service
Permissions Permissions
^^^^^^^^^^^ ^^^^^^^^^^^
In case you want to override the permissions under which the files and folders If you enabled the ``Ignore Permissions`` option in the Syncthing client's
are created (especially because Windows does not have a concept of group folder settings, then you will also need to add the line ``UMask=0002`` (or any
permissions), you enable the ``Ignore Permissions`` option in the folder other `umask setting <http://www.tech-faq.com/umask.html>` you like) in the
settings, and add the line ``UMask=0002`` (or any other umask you like) in the
``[Service]`` section of the ``syncthing@.service`` file. ``[Service]`` section of the ``syncthing@.service`` file.
Debugging Debugging
^^^^^^^^^ ^^^^^^^^^
If you are asked on the bugtracker to start Syncthing with specific If you are asked on the bugtracker to start Syncthing with specific
environment variables it will not work the easy way. Systemd isolates each environment variables it will not work the normal way. Systemd isolates each
service and it cannot access global environment variables. The solution is to service and it cannot access global environment variables. The solution is to
add this variables to the service file instead. Just use:: add the variables to the service file instead.
To edit the system service, run::
systemctl edit syncthing@myuser.service systemctl edit syncthing@myuser.service
To edit the user service, run::
systemctl --user edit syncthing.service systemctl --user edit syncthing.service
This will create an additional configuration file automatically and you This will create an additional configuration file automatically and you