Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to Content
PyoDocs

The pyo CLI

Deploy and manage your services from a terminal or CI.

The CLI is separate from Pyo itself. Pyo runs on your server, and the CLI runs on your computer or in CI. pyo is for a laptop and CI. pyo-server sets up a server.

Install

On Linux and macOS:

curl -fsSL https://pyo.dev/cli.sh | sh

It downloads the CLI for your system from Pyo's latest release on GitHub and checks it against the release's checksum. It works on Linux and macOS, on both x86-64 and Arm. It installs to /usr/local/bin when you can write there, and ~/.local/bin otherwise. Set PYO_INSTALL_DIR to choose another folder, or PYO_VERSION for a release other than the latest.

Windows

In PowerShell:

$dir = "$env:LOCALAPPDATA\Programs\pyo"
$url = "https://github.com/upsetdev/pyo/releases/latest/download/pyo-windows-x86_64.exe"
New-Item -ItemType Directory -Force $dir | Out-Null
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest $url -OutFile "$dir\pyo.exe"
Invoke-WebRequest "$url.sha256" -OutFile "$dir\pyo.exe.sha256"
$want = (Get-Content "$dir\pyo.exe.sha256").Split(" ")[0]
Remove-Item "$dir\pyo.exe.sha256"
if ((Get-FileHash "$dir\pyo.exe").Hash -ne $want) { Remove-Item "$dir\pyo.exe"; throw "The download doesn't match its checksum. Try again." }
$path = [Environment]::GetEnvironmentVariable("Path", "User")
if ($path -notlike "*$dir*") { [Environment]::SetEnvironmentVariable("Path", "$path;$dir", "User") }

This installs pyo.exe in your user folder and adds it to your Path. Open a new terminal to use it. The CLI runs on Windows on x86-64.

Download it yourself

Each release on GitHub has the CLI for every system, each with a .sha256 checksum:

SystemFile
Linux, x86-64pyo-linux-x86_64
Linux, Armpyo-linux-aarch64
macOS, Apple siliconpyo-macos-aarch64
macOS, Intelpyo-macos-x86_64
Windows, x86-64pyo-windows-x86_64.exe

Rename it to pyo (or pyo.exe on Windows) and put it in a folder on your PATH. On Linux and macOS, make it runnable with chmod +x pyo.

macOS blocks a CLI you download in a browser from opening. Clear the block with xattr -d com.apple.quarantine pyo. The curl install above doesn't need this.

On other systems, build the CLI from source with cargo build --release -p pyo-cli.

Sign in

pyo login --url https://your-pyo

This shows a code and opens your browser. Type the code there to approve the sign-in. It works over SSH too: open the link it prints on any device. It makes an API key for this computer that lasts a year. Run pyo login again for a new one. It remembers your Pyo, so --url is only needed the first time. Without it, it asks for the address. Use --expires to choose 30d, 90d, 1y or never.

Your Pyo shows these commands with its own address under API keys.

Choose which service this folder deploys. This writes pyo.jsonc.

pyo link

Deploy

pyo deploy

This applies pyo.jsonc, deploys and follows the rollout to the end. The build and deploy logs show as it goes, and pyo deploy exits with an error when the deploy fails. Use --detach to start it and exit.

Another service

Commands work on the service pyo.jsonc is linked to. Pass -s to name another one:

pyo deploy -s shop/worker

The folder's pyo.jsonc belongs to its own service, so its settings don't apply to the one -s names. pyo deploy says so and deploys without them. A deploy that would send this folder to the other service stops instead, so its files never go there. Run that deploy from the other service's own folder.

Deploy a folder

You don't need a Git repository. In a folder no service is linked to, pyo deploy makes a service from it:

cd my-app
pyo deploy

It asks for a name (the folder's by default) and a project, creates the service, links the folder in pyo.jsonc and deploys it. In CI, pass --name and --project instead (a project that doesn't exist yet is created). --team and --cluster choose where it runs.

The folder is packed and uploaded to Pyo, which hands it to a builder in the service's cluster. It's built like a repository: with its Dockerfile, or without one by detecting the language. Pyo deletes the upload once the builder has it.

✓ Packed 214 files, 1.8 MB
✓ Uploaded 1.8 MB
✓ Created acme/shop/my-app and linked it in pyo.jsonc
Deploying my-app https://your-pyo/acme/shop/my-app/deployments/dpl_8f2k1m3x9q

Run pyo deploy again to send the folder as it is now. The dashboard shows each of these deployments as Uploaded from your computer's name, and you can roll back to any of them.

What's sent:

  • Every file in the folder, except what .gitignore leaves out. A .pyoignore file, written like a .gitignore, leaves out more, or keeps something back in with !.
  • Never .git. Never node_modules, unless .pyoignore keeps it with !node_modules/.
  • No .env files, since they usually hold secrets. .env.example and the like are sent. Pass --include-env to send .env files too, or set the variables with pyo env push instead.
  • At most 500 MB, packed. A bigger folder stops before it uploads and says what's biggest.

A service built from Git deploys its branch as usual. To try your working copy on it without a commit, send the folder instead:

pyo deploy --local

Everyday commands

pyo status            # state, live version and domains
pyo logs --follow     # follow the logs
pyo env set KEY=value # set a variable
pyo rollback          # put back the previous version
pyo exec              # open a shell in the service
pyo open              # open it on the dashboard

Logs

pyo logs                      # the last lines of every replica
pyo logs -f                   # and new ones as they come
pyo logs --since 10m          # only the last 10 minutes
pyo logs --replica x2kfp      # one replica
pyo logs --build              # the latest deployment's build and deploy log
pyo logs --build -f           # followed until it's done

Each line starts with its time and the replica it came from. Times are in UTC. pyo logs -f keeps one stream open to the cluster, and opens it again if it drops.

JSON output

Add --json to a read command to print its data as JSON and nothing else, for scripts and agents:

pyo status --json         # the whole service
pyo logs --json           # the lines, as one array
pyo logs -f --json        # one object per line, as they come
pyo env list --json       # the variables, secrets with an empty value

It works with whoami, status, logs, env list, domain list, firewall list, volume list, volume snapshots, cloudflare zones and cloudflare tunnel status. In pyo sandbox, it works with create, ls, get, token, ports ls, servers ls and templates ls. It can go before or after the command. Other commands stop with an error that lists these. Exit codes are the same as without it.

Run a command

pyo exec                                  # a shell
pyo exec -- bin/rails db:migrate          # one command
pyo exec -- sh -c 'echo $DATABASE_URL'    # through a shell
pyo exec -- pg_dump app > app.sql         # output to a file
cat seed.sql | pyo exec -- psql app       # input from a pipe

Everything after -- runs as it is, in a running replica, and pyo exec exits with its exit code, so scripts can check it. It runs without a shell, so use sh -c for pipes or variables. A command gets a terminal when you run it from one, else its output and errors stay apart and piped input goes to it. -t always gives it a terminal, -T never does, and -i sends what you type without one. --replica picks the replica.

Running a command needs the Developer role, and an API key with deploy or full access. A shell needs full access.

Variables to a .env file

pyo env pull                   # write the variables to .env
pyo env pull --file .env.prod  # or another file
pyo env pull --secrets         # with the secrets' values

It won't overwrite a file unless you pass --force. Secrets are written with an empty value and a comment, unless you pass --secrets. Only team owners and admins can pull secrets' values, and each one is logged like when it's revealed on the dashboard. The file is readable only by you.

Volumes

pyo volume list                          # your teams' volumes
pyo volume snapshots shop/web-data       # its backups, newest first
pyo volume restore shop/web-data         # pick a backup and restore it
pyo volume delete-backup shop/web-data   # pick a backup and delete it
pyo volume resize shop/web-data 50       # grow it to 50 GB
pyo volume attach web-data -s blog/api   # attach it, moving it to blog if needed

pyo volume restore stops the volume's service, restores the backup and starts the service again. It waits until the restore is done, and so does pyo volume attach when it moves a volume. Add --detach to not wait. Team owners and admins can restore, delete backups and resize.

Variables from a .env file

pyo env push                     # set the variables in .env
pyo env push .env.production --secret STRIPE_KEY
pyo env push --dry-run           # see what would change

New keys are saved as variables. Pass --secret KEY to save one as a secret, or --secrets for all of them. A secret you overwrite stays a secret. For keys that are already set, it asks you on a terminal. In CI, pass --overwrite or --skip-existing. Changes apply on the next deploy, or add --deploy to deploy now.

Domains

pyo domain list                      # domains, their status and HTTPS
pyo domain add shop.example.com      # prints the DNS record to create
pyo domain add --free                # a free nip.io domain, no DNS needed
pyo domain add shop.example.com --wait
pyo domain remove shop.example.com

Domains apply right away, without a redeploy. --wait waits until the domain is live. A tailnet name, like blog.<tailnet>.ts.net, needs no DNS record.

Backups

pyo backup now                     # the service's volume
pyo backup now --volume shop/web-data --wait
pyo backup now --db cache          # a KV database, or one added under Backups

Backups go to the team's backup destination, set up under Backups on the dashboard. --wait follows the backup and prints its size and time.

Set up coding agents

pyo agents                           # pick the clients from a list
pyo agents --client claude,cursor    # or name them
pyo agents --dry-run                 # see what would change

It writes a Pyo section in AGENTS.md, or in CLAUDE.md when the folder has only that one. The section has your Pyo's address, the service pyo.jsonc links, the commands to deploy, check status, read logs and roll back, and the docs index at https://pyo.dev/llms.txt. It goes between <!-- pyo:start --> and <!-- pyo:end -->. Run it again and it replaces only that part.

--client adds Pyo's MCP server to each client's project config, and keeps everything else in the file:

Client--clientFile
Claude Codeclaude.mcp.json
Cursorcursor.cursor/mcp.json
VS Codevscode.vscode/mcp.json
Codexcodex.codex/config.toml

No key or token goes in these files. Each client signs in to Pyo with OAuth the first time it uses it. Codex reads .codex/config.toml only in projects you trust. Sign it in with codex mcp login pyo.

It shows the changes and asks before it writes. --yes writes without asking. A config file it can't change safely, like JSON with comments, is left as it is, and it prints what to add yourself. It points the agents to the Pyo you signed in to, or to --url or PYO_URL when set.

Import from another platform

pyo import coolify --from https://coolify.example.com --source-token <token>

It shows what each project, service and database becomes, then asks before it imports. Use dokploy for Dokploy. See Importing from another platform.

Upgrade

pyo upgrade

This replaces pyo with the latest release for your system, after checking its checksum. It says when you already have the latest. Add --version 0.3.0 for a particular release. If you can't write to the folder pyo is in, run it as a user who can, or install it again into a folder of yours.

Once a day, the CLI looks for a new release. When there is one, it says so after a command:

Pyo CLI 0.3.0 is out (you have 0.2.5). Run pyo upgrade.

It looks in the background, so commands never wait for it, and it stays quiet when you're offline. It doesn't look in CI, when its output isn't a terminal, or when PYO_NO_UPDATE_CHECK=1 is set.

The CLI can be newer than your Pyo. When it is a minor version or more ahead, pyo login and pyo link say so, since newer commands may not work until you update Pyo under Settings › Updates.

See every command in the command reference.