Open History to see the last commit
1# Running T3 Code in the background
2
3On Linux and macOS, T3 Code can run as a service for your user so you do not need
4to keep a terminal open.
5
6## Manage the service
7
8Run these commands on the machine that will host T3 Code:
9
10| Task | Command |
11| ------------------------------- | --------------------------------- |
12| Install and start | `npx t3@latest service install` |
13| Inspect status and log location | `npx t3@latest service status` |
14| Update or repair | `npx t3@latest service update` |
15| Stop and remove from startup | `npx t3@latest service uninstall` |
16
17Uninstalling the service leaves your projects, threads, and settings intact.
18
19Install and update use the version of the CLI you invoke. For nightly, use
20`npx t3@nightly service update`; replace `nightly` with an exact version to pin
21one. An older CLI refuses to replace a newer service unless you explicitly add
22`--allow-downgrade`.
23
24Updating restarts the server. Finish active work first, and wait for any remote
25update already in progress. To match a remote client's version, follow
26[Updating T3 Code](./updating.md).
27
28## Platform support
29
30Linux needs systemd user services. Setup enables lingering so T3 Code starts at
31boot and keeps running after logout. If this needs administrator permission,
32setup prints a recovery command before changing the service.
33
34macOS starts the service when you log in and stops it when you log out. Keep the
35Mac logged in and awake for unattended remote access. Installing over SSH while
36nobody is logged in at the Mac's screen can fail at the final start step; the
37service is still installed and will start at the next login.
38
39Windows background services are not supported.
40
41T3 Connect can offer service installation during setup, but the two are managed
42separately. Signing out of T3 Connect does not stop or uninstall the service.
43
44## Troubleshooting
45
46Start with `t3 service status` on the host. It prints the log path and, on Linux,
47checks whether the installed service is running, enabled, and allowed to survive
48logout.
49
50If it stops when your SSH session closes, check for `linger-disabled`. An
51administrator can enable lingering with:
52
53```sh
54sudo loginctl enable-linger "$(id -un)"
55```
56
57Over SSH, allow sudo to prompt:
58
59```sh
60ssh -t your-server 'sudo loginctl enable-linger "$(id -un)"'
61```
62
63Then retry service setup as your normal user. Run only the `loginctl` command
64with sudo; running T3 Code as root creates a separate installation and Connect
65identity. Without administrator access, run `t3 serve` in a terminal and keep
66that session open.
67
68| Status problem | Next step |
69| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
70| `linger-unavailable` | Run `loginctl show-user "$(id -un)" --property=Linger` and check that systemd-logind is available. |
71| `user-manager-unavailable` | Run `systemctl --user status` in a login session for the service user; check your distribution's systemd user-session support. |
72| `service-disabled` or `service-stopped` | Read the log and `systemctl --user status t3code.service`, then use the repair command printed by T3 Code. |
73
74On macOS, check **System Settings → General → Login Items** if the service no
75longer starts at login. If agent work cannot access Desktop, Documents, or
76Downloads, it may need Full Disk Access for the Node executable listed in
77`ProgramArguments` in
78`~/Library/LaunchAgents/com.t3tools.t3code.service.plist`.
79
80For failures after signing in to T3 Connect, see
81[connection troubleshooting](./remote-access.md#t3-connect-troubleshooting).