summaryrefslogtreecommitdiff
path: root/assets/2026-01-21-syncthing-service-conflict.org
blob: 7f86b39be946d2d4b2fc4c1cb9ec09b3c29ca81e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#+TITLE: Syncthing Service Conflict Issue
#+DATE: 2026-01-21

* Problem

archsetup enables the system service:
#+begin_src bash
systemctl enable "syncthing@$username.service"
#+end_src

However, the user service can also get enabled (either by default or manually):
#+begin_src bash
systemctl --user enable syncthing.service
#+end_src

When BOTH services are enabled, they fight over the same lock file:
=~/.local/state/syncthing/syncthing.lock=

This causes one or both to fail with:
: Failed to acquire lock: is another Syncthing instance already running?

* Symptoms

- Syncthing fails to start or keeps crashing
- Lock file errors in journalctl
- Two syncthing processes running with different parent services
- Config changes don't persist (one service overwrites the other)

* Recommendation

Standardize on ONE service type. Options:

** Option A: User Service (recommended for desktops)

Runs when user logs in. Cleaner for desktop use.

Change archsetup from:
#+begin_src bash
systemctl enable "syncthing@$username.service"
#+end_src

To:
#+begin_src bash
# Enable user service (requires user session)
sudo -u "$username" systemctl --user enable syncthing.service
#+end_src

Note: User services require lingering or an active session:
#+begin_src bash
loginctl enable-linger "$username"
#+end_src

** Option B: System Service (recommended for headless/servers)

Runs at boot without user login. Better for servers.

Keep current archsetup config, but ensure user service is disabled:
#+begin_src bash
systemctl enable "syncthing@$username.service"
# Explicitly disable user service to prevent conflicts
sudo -u "$username" systemctl --user disable syncthing.service 2>/dev/null || true
#+end_src

* Resolution on ratio (2026-01-21)

Disabled system service, kept user service:
#+begin_src bash
sudo systemctl stop syncthing@cjennings.service
sudo systemctl disable syncthing@cjennings.service
systemctl --user enable syncthing.service
systemctl --user start syncthing.service
#+end_src