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
28Self-contained builds install as a download from the T3 Code GitHub release
29instead of through npm, so the machine running the service does not need
30Node.js or npm once the CLI is on it. To get the CLI onto a machine without
31Node, run the install script:
32
33```sh
34curl -fsSL https://t3.codes/install.sh | sh
35```
36
37On Windows, run `irm https://t3.codes/install.ps1 | iex` in PowerShell instead.
38
39It places `t3` in `~/.local/bin` and reuses the same download when you later
40run `t3 service install`. It follows the stable train by default; set
41`T3CODE_CHANNEL=nightly` for nightlies, `T3CODE_VERSION` to pin an exact
42version, or `T3CODE_RELEASE_BASE_URL` to download from a mirror.
43
44`preview` is a third train that maintainers cut from unreleased branches to
45exercise the release pipeline. Those builds can be broken, receive no fixes,
46and are never offered as updates; the installer and `t3 update` only take you
47there when you ask for the channel explicitly, and warn you when they do.
48
49Once a self-contained `t3` is installed, `t3 update` moves the machine to a
50newer one without npm: it downloads the newest release on the channel the
51running `t3` came from, verifies it, and points the `t3` launcher at it. When
52a background service is installed for the same T3 home it asks before
53restarting it, since a restart interrupts running agent turns, terminals, and
54remote clients; answer no and the service keeps the old version until you run
55`t3 service update`. From a script there is no prompt, so pass `--yes` to
56restart the service. A server you started by hand is never touched; the
57command tells you it is still on the old version so you can restart it
58yourself. Pass an exact version (`t3 update 0.0.41-preview.20260912.1595`) to
59pin one, `--channel` to follow a different release train (moving onto preview from stable or nightly asks for confirmation), or
60`--allow-downgrade` to move backwards.
61
62`t3 uninstall` reverses the install script: it shows what it found (the
63background service, the `t3` launcher, every downloaded version under
64`~/.t3/runtime`), asks once, and removes them. Your projects, threads, and
65settings under `~/.t3/userdata` are kept; delete that directory yourself if
66you want them gone too. Pass `--yes` from a script.
67
68## Platform support
69
70Linux needs systemd user services. Setup enables lingering so T3 Code starts at
71boot and keeps running after logout. If this needs administrator permission,
72setup prints a recovery command before changing the service.
73
74macOS starts the service when you log in and stops it when you log out. Keep the
75Mac logged in and awake for unattended remote access. Installing over SSH while
76nobody is logged in at the Mac's screen can fail at the final start step; the
77service is still installed and will start at the next login.
78
79Windows background services are not supported.
80
81T3 Connect can offer service installation during setup, but the two are managed
82separately. Signing out of T3 Connect does not stop or uninstall the service.
83
84## Troubleshooting
85
86Start with `t3 service status` on the host. It prints the log path and, on Linux,
87checks whether the installed service is running, enabled, and allowed to survive
88logout.
89
90If it stops when your SSH session closes, check for `linger-disabled`. An
91administrator can enable lingering with:
92
93```sh
94sudo loginctl enable-linger "$(id -un)"
95```
96
97Over SSH, allow sudo to prompt:
98
99```sh
100ssh -t your-server 'sudo loginctl enable-linger "$(id -un)"'
101```
102
103Then retry service setup as your normal user. Run only the `loginctl` command
104with sudo; running T3 Code as root creates a separate installation and Connect
105identity. Without administrator access, run `t3 serve` in a terminal and keep
106that session open.
107
108| Status problem | Next step |
109| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
110| `linger-unavailable` | Run `loginctl show-user "$(id -un)" --property=Linger` and check that systemd-logind is available. |
111| `user-manager-unavailable` | Run `systemctl --user status` in a login session for the service user; check your distribution's systemd user-session support. |
112| `service-disabled` or `service-stopped` | Read the log and `systemctl --user status t3code.service`, then use the repair command printed by T3 Code. |
113| `restart-pending` | A newer version is installed but the service still runs the previous one. Run `t3 service restart`. |
114
115On macOS, check **System Settings → General → Login Items** if the service no
116longer starts at login. If agent work cannot access Desktop, Documents, or
117Downloads, it may need Full Disk Access for the Node executable listed in
118`ProgramArguments` in
119`~/Library/LaunchAgents/com.t3tools.t3code.service.plist`.
120
121For failures after signing in to T3 Connect, see
122[connection troubleshooting](./remote-access.md#t3-connect-troubleshooting).