Skip to content

Latest commit

 

History

History
195 lines (135 loc) · 7.66 KB

File metadata and controls

195 lines (135 loc) · 7.66 KB

Deploy AnyCode as a systemd user service

中文 | English

GitHub Releases provide Linux binary archives as well as Debian, Red Hat, and Arch Linux packages. They all contain the anycode executable with the web UI embedded, a systemd user unit, and an environment-file example.

AnyCode runs as the current login user and directly reuses that user's HOME, ~/.codex credentials, and project access. No additional system account is created. The Codex CLI is still required on the host. cloudflared is needed only for Cloudflare quick tunnels.

Supported platforms

  • Linux x86-64: amd64
  • Linux ARM64: arm64
  • A distribution that uses systemd and glibc (the packages do not support musl)

Distribution packages use their native architecture names:

Platform Debian Red Hat Arch Linux
x86-64 amd64 x86_64 x86_64
ARM64 arm64 aarch64 aarch64

The aarch64 package targets Arch Linux ARM; the official Arch Linux repositories themselves support only x86-64.

Install a distribution package

The examples below use 1.2.3 and x86-64. Select the command group for your system; do not install multiple formats.

Debian or Ubuntu:

VERSION=1.2.3
ARCH=amd64
curl -fLO "https://github.com/nzlov/anycode/releases/download/v${VERSION}/anycode_${VERSION}_${ARCH}.deb"
curl -fLO "https://github.com/nzlov/anycode/releases/download/v${VERSION}/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
sudo apt install "./anycode_${VERSION}_${ARCH}.deb"

RHEL, Fedora, or another RPM-based system:

VERSION=1.2.3
ARCH=x86_64
curl -fLO "https://github.com/nzlov/anycode/releases/download/v${VERSION}/anycode-${VERSION}-1.${ARCH}.rpm"
curl -fLO "https://github.com/nzlov/anycode/releases/download/v${VERSION}/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
sudo dnf install "./anycode-${VERSION}-1.${ARCH}.rpm"

Arch Linux or Arch Linux ARM:

VERSION=1.2.3
ARCH=x86_64
curl -fLO "https://github.com/nzlov/anycode/releases/download/v${VERSION}/anycode-${VERSION}-1-${ARCH}.pkg.tar.zst"
curl -fLO "https://github.com/nzlov/anycode/releases/download/v${VERSION}/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
sudo pacman -U "./anycode-${VERSION}-1-${ARCH}.pkg.tar.zst"

Distribution packages install the Git and systemd dependencies and place these files under package-manager control:

  • /usr/bin/anycode
  • /usr/lib/systemd/user/anycode.service
  • /usr/share/anycode/anycode.env.example

Distribution packages attached to a Release are not signed with distribution repository keys; verify downloads with checksums.txt from the same Release.

Create a private configuration for the current user:

install -d -m 0700 ~/.config/anycode
install -m 0600 /usr/share/anycode/anycode.env.example ~/.config/anycode/anycode.env

Package installation and upgrades do not overwrite ~/.config/anycode/anycode.env or automatically start a service for any user.

Install the binary archive

The example below uses v1.2.3 and amd64. Replace both values with the target Release and host architecture.

VERSION=v1.2.3
ARCH=amd64
curl -fLO "https://github.com/nzlov/anycode/releases/download/${VERSION}/anycode-${VERSION}-linux-${ARCH}.tar.gz"
curl -fLO "https://github.com/nzlov/anycode/releases/download/${VERSION}/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
tar -xzf "anycode-${VERSION}-linux-${ARCH}.tar.gz"
cd "anycode-${VERSION}-linux-${ARCH}"

Install the executable, then install the unit and configuration for the current user:

sudo install -m 0755 anycode /usr/bin/anycode
install -D -m 0644 systemd/anycode.service ~/.config/systemd/user/anycode.service
install -D -m 0600 systemd/anycode.env.example ~/.config/anycode/anycode.env

Configure Codex and AnyCode

First verify that the current user is signed in to Codex:

codex login --device-auth
codex login status
command -v codex

The user service searches ~/.local/bin, /usr/local/bin, and /usr/bin by default. If command -v codex reports another directory, put its absolute path in CODEX_BIN inside ~/.config/anycode/anycode.env.

Edit ~/.config/anycode/anycode.env and replace at least ANYCODE_ACCESS_KEY. The environment file is not a shell script: use plain KEY=value assignments without export, command substitution, or references to other variables.

The service stores its database, attachments, artifacts, and worktrees in ~/.local/share/anycode by default. Projects can be located anywhere accessible to the current user; add them in the web UI using their real host paths.

The service listens only on 127.0.0.1:8080 by default. For remote access, keep the loopback listener and expose it through a trusted TLS reverse proxy. AnyCode inherits the current user's file permissions, so its access key grants the ability to read those directories and execute project commands; it does not provide transport encryption.

Start and inspect the service

Run the following systemctl --user commands as the user that will run AnyCode. Do not use sudo systemctl --user.

An always-on server deployment must run after boot without an interactive login. First, explicitly enable lingering for the current user. Skip this step if AnyCode only needs to run while that user is logged in:

sudo loginctl enable-linger "$USER"
loginctl show-user "$USER" -p Linger

Confirm that the output contains Linger=yes. Distribution packages do not automatically enable lingering for any user because it is a host-level policy that affects all systemd user services for that user.

Then load the unit, enable AnyCode, and inspect it:

systemctl --user daemon-reload
systemctl --user enable --now anycode
systemctl --user status anycode
systemctl --user is-enabled anycode
curl --fail http://127.0.0.1:8080/healthz

Follow the logs with:

journalctl --user -u anycode -f

If startup logs contain probe codex cli, check CODEX_BIN and the current user's codex login status.

Upgrade

Back up ~/.local/share/anycode and ~/.config/anycode before upgrading.

When using a distribution package, download and verify the new Release, then run the corresponding apt install, dnf install, or pacman -U command again. The user running the service must then load the new unit and restart:

systemctl --user daemon-reload
systemctl --user restart anycode
systemctl --user status anycode

When using the binary archive, replace /usr/bin/anycode first. If the unit changed, copy it to ~/.config/systemd/user/anycode.service, then run the user-service commands above. The environment-file example never overwrites the existing configuration automatically.

Uninstall

First stop and disable the service as every user currently running AnyCode:

systemctl --user disable --now anycode

If lingering was enabled specifically for AnyCode, disable it only after confirming that this user has no other user services that must run while logged out:

sudo loginctl disable-linger "$USER"

Lingering affects all systemd user services for that user. Do not disable it when another service still depends on it.

When using a distribution package, select the command for the current system:

sudo apt remove anycode
sudo dnf remove anycode
sudo pacman -R anycode

When using the binary archive:

rm ~/.config/systemd/user/anycode.service
systemctl --user daemon-reload
sudo rm /usr/bin/anycode

Uninstallation does not automatically delete ~/.config/anycode, ~/.local/share/anycode, or project directories. Remove them separately only after confirming that they are no longer needed.