Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

background-service.md

89 lines3.3 KB

1# Running T3 Code in the Background
2​
3On Linux and macOS, T3 Code can run as a background service for your user, so it is ready without
4keeping a terminal open.
5​
6## Manage the Service
7​
8Install it with the latest T3 Code release:
9​
10```sh
11npx t3@latest service install
12```
13​
14Check whether it is installed:
15​
16```sh
17npx t3@latest service status
18```
19​
20Update or repair it:
21​
22```sh
23npx t3@latest service update
24```
25​
26The service uses the same T3 Code version as the CLI you run. To install a nightly or an exact
27version, use that version of the CLI:
28​
29```sh
30npx t3@nightly service update
31npx t3@1.2.3 service update
32```
33​
34The install and update commands refuse to replace a newer service with an older version. Setup
35through T3 Connect leaves a newer service unchanged. To downgrade, select the exact older version
36and pass `--allow-downgrade`:
37​
38```sh
39npx t3@1.2.3 service update --allow-downgrade
40```
41​
42Stop it and remove it from startup:
43​
44```sh
45npx t3@latest service uninstall
46```
47​
48Updating restarts T3 Code briefly. Let active agent work and terminal commands finish first.
49If a remote update is already in progress, wait for it to finish before retrying a local update.
50​
51The service runs a small stable launcher. Exact T3 Code versions are installed separately, so a
52failed remote candidate can return to the previous version without rewriting the service
53definition. The launcher snapshots the database before a remote candidate starts, so database
54updates roll back with the server version. An older launcher may require one local
55`service update` before this is available.
56​
57## Platform Support
58​
59**Linux** uses a systemd user unit at `~/.config/systemd/user/t3code.service`. The service starts
60when the machine boots and keeps running after you log out (lingering is enabled during install).
61​
62**macOS** uses a launch agent at `~/Library/LaunchAgents/com.t3tools.t3code.service.plist`. It
63starts when you log in, not when the Mac boots, and it stops when you log out; macOS has no
64equivalent of Linux lingering for user agents. For a Mac that should stay reachable unattended,
65turn on automatic login (System Settings → Users & Groups; unavailable while FileVault is on) and
66keep the Mac from sleeping.
67​
68A few more macOS notes:
69​
70- Installing over SSH needs someone logged in at the Mac's screen to start the agent right away.
71 Without that, the install command reports an error at the final start step, but the agent is
72 fully installed and starts at the next login.
73- macOS may show privacy prompts for protected folders such as Desktop, Documents, or Downloads,
74 attributed to a bare `node` process, or deny access without a prompt. If agent work fails to
75 read those folders, grant Full Disk Access to the node binary listed in the launch agent's
76 `ProgramArguments`.
77- The agent appears under System Settings → General → Login Items. If it was switched off there,
78 or disabled with `launchctl disable`, macOS will not start it at login until you switch it back
79 on.
80​
81**Windows** is not supported yet.
82​
83## Using It with T3 Connect
84​
85T3 Connect may offer to install the service during setup so the host stays reachable in the
86background. This is only an onboarding shortcut: the service and T3 Connect are managed separately.
87​
88Signing out of T3 Connect does not remove the service. Use `t3 service uninstall` when you no longer
89want T3 Code to start in the background.