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

perkhost commands
CommandWhat 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 logoutRemoves 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 helpShows the help. --help and -h do the same.
perkhost --versionShows the version. -v does the same.
perkhost options
OptionApplies toMeaning
--workspace <id>loginThe workspace the token belongs to. A token belongs to one workspace.
--plan <id>deployThe plan for a new app: launch, build, grow, scale, turbo. Required with --yes when the terminal is not interactive.
--region <code>deployThe region for a new app. The default is blr1.
--yes, -ydeployConfirms creating a billable app without asking.
--debugevery commandPrints one redacted line per API request.

Sign in

  1. Create an API token for the workspace with the members:read scope. See "API tokens".
  2. Run perkhost login --workspace <workspace id> and paste the token when asked. Nothing is echoed.
  3. The CLI checks the token by listing the workspace members, which needs the members:read scope 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

Environment variables the CLI reads
VariableMeaning
PERKHOST_TOKENAPI 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_WORKSPACEThe workspace id the token belongs to.
PERKHOST_API_URLThe API origin. The default is https://api.perkhost.com.

What deploy does

  1. Reads the project folder and detects the stack. See "Stacks and perkhost.json".
  2. Packs it into a compressed bundle. The limit is 100 MiB compressed, on every plan, and it is checked before anything is uploaded.
  3. 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.
  4. 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

perkhost exit codes
CodeMeaning
0Success.
1An unexpected error.
2The command line was wrong: an unknown command or option, a missing value, or a token passed as an argument.
10Not signed in. Run perkhost login or set the environment variables.
11The API token is not valid.
12No stack could be detected from the project, or perkhost.json is invalid.
13The project uses a stack that is not supported, such as a Dockerfile.
14The project is above the upload limit.
15The workspace plan does not allow this.
16A payment method is required.
17The app name is taken.
18No server has room.
19The stack is not available.
20The plan or region is not available.
21Another operation on the app is in progress, or a newer deploy replaced this one.
22The deployment failed. The previous release, if any, keeps serving.
23The deployment was still running when the CLI stopped waiting. It continues on PerkHost.
24The API could not be reached.
25Not found.
26Not allowed.
27Creating a billable app needs confirmation. Nothing was created.
130Interrupted with Ctrl+C.