Command line
The perkhost command
The perkhost command line: login, logout and deploy, the environment variables it reads and its exit codes.
perkhost deploy cannot finish yet
App hosting is not available, so the API has no apps or deployments to talk to. The CLI is not offered as a download on this site yet, so this page is a reference for the build in the source, not an install guide.
Commands
| Command | What it does |
|---|---|
| perkhost login [--workspace <id>] | Stores a workspace API token. The token is asked for with hidden input and is never an argument. |
| perkhost logout | Removes the stored token from this machine. |
| perkhost deploy [name] | Detects the stack, creates the app if needed, uploads the project, starts it and prints the URL. |
| perkhost help | Shows the help. --help and -h do the same. |
| perkhost --version | Shows the version. -v does the same. |
| Option | Applies to | Meaning |
|---|---|---|
| --workspace <id> | login | The workspace the token belongs to. A token belongs to one workspace. |
| --plan <id> | deploy | The plan for a new app: launch, build, grow, scale, turbo. Required with --yes when the terminal is not interactive. |
| --region <code> | deploy | The region for a new app. The default is blr1. |
| --yes, -y | deploy | Confirms creating a billable app without asking. |
| --debug | every command | Prints one redacted line per API request. |
Sign in
- Create an API token for the workspace with the
members:readscope. See "API tokens". - Run
perkhost login --workspace <workspace id>and paste the token when asked. Nothing is echoed. - The CLI checks the token by listing the workspace members, which needs the
members:readscope and the developer role or higher, and only then saves it. A token without that scope is refused and nothing is saved.
The token is stored in the operating system keychain where one is available, and otherwise in a private file. The CLI refuses a token given as an argument (--token, -t, --api-key or --password), because arguments end up in shell history and process lists. Browser sign-in is not part of this release.
Environment variables
| Variable | Meaning |
|---|---|
| PERKHOST_TOKEN | API token for CI and AI tools. Use it together with PERKHOST_WORKSPACE. When it is set, the CLI uses it directly and perkhost login stores nothing. |
| PERKHOST_WORKSPACE | The workspace id the token belongs to. |
| PERKHOST_API_URL | The API origin. The default is https://api.perkhost.com. |
What deploy does
- Reads the project folder and detects the stack. See "Stacks and perkhost.json".
- Packs it into a compressed bundle. The limit is 100 MiB compressed, on every plan, and it is checked before anything is uploaded.
- Looks for an app with the given name (by default the folder name) in the workspace. If there is none, asks you to confirm the plan and price, then creates it.
- Uploads the bundle, waits while the deployment moves through its statuses and prints the URL when it is live. If it fails, it prints the last 50 log lines, and the previous release, if any, keeps serving.
Files named in .gitignore or .perkhostignore are not uploaded. The .git file or folder, node_modules, .env and .env.* files, .envrc and .npmrc are never uploaded, in any letter case. Set environment variables for an app through the API instead.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | An unexpected error. |
| 2 | The command line was wrong: an unknown command or option, a missing value, or a token passed as an argument. |
| 10 | Not signed in. Run perkhost login or set the environment variables. |
| 11 | The API token is not valid. |
| 12 | No stack could be detected from the project, or perkhost.json is invalid. |
| 13 | The project uses a stack that is not supported, such as a Dockerfile. |
| 14 | The project is above the upload limit. |
| 15 | The workspace plan does not allow this. |
| 16 | A payment method is required. |
| 17 | The app name is taken. |
| 18 | No server has room. |
| 19 | The stack is not available. |
| 20 | The plan or region is not available. |
| 21 | Another operation on the app is in progress, or a newer deploy replaced this one. |
| 22 | The deployment failed. The previous release, if any, keeps serving. |
| 23 | The deployment was still running when the CLI stopped waiting. It continues on PerkHost. |
| 24 | The API could not be reached. |
| 25 | Not found. |
| 26 | Not allowed. |
| 27 | Creating a billable app needs confirmation. Nothing was created. |
| 130 | Interrupted with Ctrl+C. |