Docs/ CLI/ Referencia de comandos

Referencia de comandos

Los 48 comandos de la versión publicada (v1.10.2), agrupados por tarea. Cada bloque de abajo es el <code>--help</code> del comando reducido a su sintaxis: lo que lees aquí es lo que acepta el binario.

Configuración y opciones globales

La mayoría de los comandos hablan con un servidor sh0 a través de su API. Lo encuentran en este orden:

  • Las variables de entorno SH0_API_URL y SH0_API_TOKEN, cuando ambas están definidas -- la vía para la integración continua. Tienen prioridad sobre el archivo.
  • El archivo ~/.sh0/config.toml, escrito por sh0 login. sh0 config show muestra el servidor y un token enmascarado; sin ninguno de los dos, los comandos se detienen con «No configuration found. Run `sh0 login` or set SH0_API_URL and SH0_API_TOKEN environment variables.»
  • Las opciones globales son solo --log-level, -h, --help y -V, --version. --config apunta al archivo de configuración del servidor (/etc/sh0/config.toml) y solo afecta a los comandos que se ejecutan en el servidor, como sh0 serve.
  • --json es una opción de cada comando: existe donde la referencia de abajo la muestra (listados, cron runs…), no en todas partes.
Terminal
$ sh0 whoami
  Server:  https://panel.example.com
  User:    [email protected]
  Role:    owner

$ SH0_API_URL=https://panel.example.com SH0_API_TOKEN=sh0_... sh0 apps
  NAME      STATUS    BRANCH  PORT  REPLICAS  UPDATED
  --------  --------  ------  ----  --------  -------
  my-api    running   main    3001  1         2m ago
Warning
No existe ninguna opción global --url, --token, --json ni --verbose. Un script escrito según una versión anterior de esta página que las usaba falla con «unexpected argument»: usa en su lugar las variables de entorno anteriores.

Cómo leer los bloques: <APP> es obligatorio, [--opción] es opcional, ... se repite. La línea que empieza por # es la descripción del propio comando. <APP> acepta el nombre o el ID de una aplicación; la mayoría de los comandos de servicios (sh0 db…) reciben un ID, que se muestra al crear el recurso y con su list.

Cuenta y configuración de la CLI

Conectar la CLI a un servidor y comprobar quién eres en él.

sh0 login

sh0 login --help
# Authenticate with a sh0 server
sh0 login [--url <URL>]

sh0 whoami

sh0 whoami --help
# Show current user and server info
sh0 whoami

sh0 config

sh0 config --help
# Show current configuration
sh0 config show
# Get a specific configuration value
sh0 config get <KEY>
# Set a configuration value
sh0 config set <KEY> <VALUE>

sh0 version

sh0 version --help
# Print version information
sh0 version

Directorio de trabajo

Vincular un directorio local a una aplicación, comprobarlo antes de desplegar y volver a desplegar con cada cambio.

sh0 init

sh0 init --help
# Initialize a project directory for sh0 deployments
sh0 init [PATH]
sh0 link --help
# Link the current directory to an existing app on the server
sh0 link <APP> [--path <PATH>]

sh0 open

sh0 open --help
# Open the app's primary domain in the default browser
sh0 open [APP]

sh0 watch

sh0 watch --help
# Watch for file changes and auto-push
sh0 watch [PATH] [--name <NAME>] [--project <PROJECT>] [--port <PORT>] [--no-check] [--timeout <TIMEOUT>] [--debounce <DEBOUNCE>]

sh0 check

sh0 check --help
# Run Code Health Check on local directory
sh0 check [PATH] [--json]

Desplegar

sh0 push envía un directorio como archivo comprimido y crea o actualiza la aplicación: es la vía principal, sin repositorio Git. Ver Desplegar con push.

sh0 push

sh0 push --help
# Push local directory to deploy (create or update)
sh0 push [PATH] [--name <NAME>] [--project <PROJECT>] [--port <PORT>] [--no-check] [--timeout <TIMEOUT>]

sh0 deploy

sh0 deploy --help
# Trigger a deployment
sh0 deploy <APP> [--message <MESSAGE>] [--wait]

sh0 templates

sh0 templates --help
# List available templates
sh0 templates list
# Show template details
sh0 templates info <NAME>
# Deploy a template
sh0 templates deploy --app-name <APP_NAME> <NAME> [--var]

sh0 compose

sh0 compose --help
# Deploy a Docker Compose file
sh0 compose deploy --app-name <APP_NAME> [PATH] [--var] [--wait]
# Validate a Docker Compose file without deploying
sh0 compose validate [PATH]

sh0 yaml

sh0 yaml --help
# Apply a sh0.yaml configuration
sh0 yaml apply [PATH]
# Validate a sh0.yaml configuration without applying
sh0 yaml validate [PATH]
# Export current configuration as sh0.yaml
sh0 yaml export [--project <PROJECT>]

sh0 export

sh0 export --help
# Export app configuration to a platform-specific format
sh0 export <APP> <FORMAT> [--output <OUTPUT>]

Gestionar aplicaciones

Ciclo de vida, variables, dominios, registros y un shell en una aplicación en marcha. Las variables se aplican en el siguiente despliegue.

sh0 apps

sh0 apps --help
# List all applications
sh0 apps [--json]

sh0 status

sh0 status --help
# Show server or app status
sh0 status [APP] [--json]

sh0 restart

sh0 restart --help
# Restart an application
sh0 restart <APP>
Warning
En una aplicación que tarda en detenerse, sh0 restart puede terminar con «operation timed out» a los 30 segundos mientras el reinicio continúa y se completa en el servidor (medido: 41 s hasta la respuesta de la API). Compruébalo con sh0 status <APP> antes de reintentar.

sh0 stop

sh0 stop --help
# Stop an application
sh0 stop <APP> [--yes]

sh0 start

sh0 start --help
# Start a stopped application
sh0 start <APP>

sh0 delete

sh0 delete --help
# Delete an application and its resources
sh0 delete <APP> [--yes]

sh0 scale

sh0 scale --help
# Scale application replicas
sh0 scale <APP> [REPLICAS] [--auto] [--status] [--json]

sh0 env

sh0 env --help
# List environment variables
sh0 env <APP> list [--reveal]
# Set an environment variable
sh0 env <APP> set <PAIR> [--build]
# Delete an environment variable
sh0 env <APP> delete <KEY>
Terminal
$ sh0 env my-api set "DATABASE_URL=postgresql://appuser:<password>@my-pg.internal:5432/appdb"
[ok] Set DATABASE_URL for 'my-api'

$ sh0 env my-api list
  KEY           VALUE    BUILD  CREATED
  ------------  -------  -----  -------
  DATABASE_URL  *******  no     4m ago
  GREETING      *******  no     16m ago

sh0 domains

sh0 domains --help
# List domains for the app
sh0 domains <APP> list
# Add a domain to the app
sh0 domains <APP> add <DOMAIN> [--primary]
# Remove a domain from the app
sh0 domains <APP> remove <DOMAIN> [--yes]

sh0 logs

sh0 logs --help
# Stream application logs
sh0 logs <APP> [--follow] [--tail <TAIL>]

sh0 ssh

sh0 ssh --help
# Execute command in app container
sh0 ssh <APP> [COMMAND]...
Note
sh0 ssh necesita un terminal interactivo (desde un script sin terminal se detiene con «cannot attach stdin to a TTY-enabled container»). Pon -- delante de un comando que tiene sus propias opciones: sh0 ssh my-api -- node --version.

Tareas programadas, hooks y previsualizaciones

Antes de crear una tarea programada, lee dónde se ejecuta su comando: no ve las variables de tu aplicación.

sh0 cron

sh0 cron --help
# List cron jobs
sh0 cron list [--app <APP>] [--json]
# Create a new cron job
sh0 cron create --app <APP> --name <NAME> --schedule <SCHEDULE> --command <COMMAND> [--image <IMAGE>] [--timeout <TIMEOUT>]
# Manually trigger a cron job
sh0 cron trigger <ID>
# Show execution history for a cron job
sh0 cron runs <ID> [--json]
# Delete a cron job
sh0 cron delete <ID> [--yes]

sh0 hooks

sh0 hooks --help
# List deploy hooks for an app
sh0 hooks <APP> list [--json]
# Create a deploy hook
sh0 hooks <APP> create --hook-type <type> --command <COMMAND> [--timeout <TIMEOUT>]
# Delete a deploy hook
sh0 hooks <APP> delete <ID>

sh0 preview

sh0 preview --help
# List preview environments for an app
sh0 preview <APP> list [--json]
# Destroy a preview environment
sh0 preview <APP> delete <ID>
# Enable preview environments for an app
sh0 preview <APP> enable [--ttl <TTL>]
# Disable preview environments for an app
sh0 preview <APP> disable

Servicios

Servidores de bases de datos, autenticación, tiempo real, funciones, correo, almacenamiento y disponibilidad. Cada comando tiene un alias corto (db, auth, realtime, fn, storage); el nombre largo también funciona.

sh0 db

sh0 db --help
# List all database servers
sh0 db list [--json]
# Show database server details
sh0 db info <ID> [--json]
# Create a new database server
sh0 db create --name <NAME> --engine <ENGINE> [--project <PROJECT>]
# Update a database server
sh0 db update <ID> [--name <NAME>] [--project <PROJECT>]
# Delete a database server
sh0 db delete <ID> [--yes]
# Start a database server
sh0 db start <ID>
# Stop a database server
sh0 db stop <ID>
# Recreate a database server container
sh0 db recreate <ID>
# Show connection info for a database server
sh0 db connection-info <ID> [--json]
# Create a database on a server
sh0 db create-database --name <NAME> <ID>
# Create a user on a database server
sh0 db create-user --username <USERNAME> --password <PASSWORD> <ID>
# Grant a user access to a database
sh0 db grant --user <USER> --database <DATABASE> <ID> [--privileges <PRIVILEGES>]
# Enable PostgREST sidecar
sh0 db enable-postgrest <ID> [--anon-role <ANON_ROLE>] [--schemas <SCHEMAS>]
# Disable PostgREST sidecar
sh0 db disable-postgrest <ID>

sh0 auth

sh0 auth --help
# List all auth servers
sh0 auth-servers list [--json]
# Show auth server details
sh0 auth-servers info <ID> [--json]
# Create a new auth server
sh0 auth-servers create --name <NAME> --database-server <DATABASE_SERVER> [--project <PROJECT>]
# Delete an auth server
sh0 auth-servers delete <ID> [--yes]
# Start an auth server
sh0 auth-servers start <ID>
# Stop an auth server
sh0 auth-servers stop <ID>

sh0 realtime

sh0 realtime --help
# List all realtime servers
sh0 realtime-servers list [--json]
# Show realtime server details
sh0 realtime-servers info <ID> [--json]
# Create a new realtime server
sh0 realtime-servers create --name <NAME> [--project <PROJECT>]
# Delete a realtime server
sh0 realtime-servers delete <ID> [--yes]
# Start a realtime server
sh0 realtime-servers start <ID>
# Stop a realtime server
sh0 realtime-servers stop <ID>

sh0 fn

sh0 fn --help
# List all function servers
sh0 function-servers list [--json]
# Show function server details
sh0 function-servers info <ID> [--json]
# Create a new function server
sh0 function-servers create --name <NAME> [--project <PROJECT>]
# Delete a function server
sh0 function-servers delete <ID> [--yes]
# Start a function server
sh0 function-servers start <ID>
# Stop a function server
sh0 function-servers stop <ID>

sh0 mail

sh0 mail --help
# List all mail domains
sh0 mail list [--json]
# Show mail domain details
sh0 mail info <ID> [--json]
# Create a new mail domain
sh0 mail create --domain <DOMAIN> [--project <PROJECT>]
# Delete a mail domain
sh0 mail delete <ID> [--yes]
# Start a mail domain
sh0 mail start <ID>
# Stop a mail domain
sh0 mail stop <ID>
# Check DNS records for a mail domain
sh0 mail dns-check <ID> [--json]
# Create a mailbox on a mail domain
sh0 mail create-mailbox --email <EMAIL> --password <PASSWORD> <ID> [--display-name <DISPLAY_NAME>]
# Create an email alias on a mail domain
sh0 mail create-alias --source <SOURCE> --destination <DESTINATION> <ID>

sh0 storage

sh0 storage --help
# List all file storage instances
sh0 file-storage list [--json]
# Show file storage instance details
sh0 file-storage info <ID> [--json]
# Create a new file storage instance
sh0 file-storage create --name <NAME> [--project <PROJECT>]
# Delete a file storage instance
sh0 file-storage delete <ID> [--yes]
# Start a file storage instance
sh0 file-storage start <ID>
# Stop a file storage instance
sh0 file-storage stop <ID>
# Create a bucket in a storage instance
sh0 file-storage create-bucket --name <NAME> <ID>
# Create an access key for a storage instance
sh0 file-storage create-key <ID> [--json]
# Show storage usage statistics
sh0 file-storage usage <ID> [--json]

sh0 uptime

sh0 uptime --help
# List uptime checks
sh0 uptime list [--app <APP>] [--json]
# Show uptime check details
sh0 uptime info <ID> [--json]
# Create a new uptime check
sh0 uptime create --app <APP> --url <URL> [--interval <INTERVAL>] [--method <METHOD>] [--timeout <TIMEOUT>] [--expected-status <EXPECTED_STATUS>] [--failure-threshold <FAILURE_THRESHOLD>]
# Delete an uptime check
sh0 uptime delete <ID> [--yes]
# List uptime incidents for a check
sh0 uptime incidents <CHECK_ID> [--json]

Servidores y panel

Los nodos remotos y el dominio del propio panel.

sh0 nodes

sh0 nodes --help
# List all server nodes
sh0 nodes list [--json]
# Show node details
sh0 nodes info <ID> [--json]
# Register a new server node
sh0 nodes create --name <NAME> --host <HOST> --ssh-user <SSH_USER> [--ssh-key <SSH_KEY>] [--password <PASSWORD>] [--port <PORT>]
# Remove a node from the cluster
sh0 nodes delete <ID> [--yes]
# Test SSH and Docker connectivity to a node
sh0 nodes test <ID> [--json]

sh0 panel-domain

sh0 panel-domain --help
# Domaine du panneau d'administration : le lire, le poser, le retirer.
sh0 panel-domain [COMMAND] [--data-dir <DATA_DIR>] [--db <DB>] [--caddy-data <CADDY_DATA>] [--jwt-secret-path <JWT_SECRET_PATH>] [--port <PORT>]
# Poser le domaine et attendre l'émission du certificat
sh0 panel-domain set <DOMAIN> [--no-wait]
# Retirer la route et le réglage
sh0 panel-domain clear

Administración del servidor

Estos comandos se ejecutan en el servidor, como root, y actúan sobre la instalación local en lugar de pasar por la API. Algunos imprimen su ayuda en francés en la versión actual.

sh0 serve

sh0 serve --help
# Start the sh0 server
sh0 serve [OPTIONS]    # sh0 serve --help lists every option

sh0 setup

sh0 setup --help
# Run initial setup wizard
sh0 setup

sh0 install-dns-caddy

sh0 install-dns-caddy --help
# Install a Caddy that can answer the DNS-01 ACME challenge (ISSUE-158).
sh0 install-dns-caddy

sh0 users

sh0 users --help
# List all users (reads the local database when run on the server box, the API otherwise)
sh0 users list [--json] [--data-dir <DATA_DIR>] [--db <DB>]
# Invite a new user
sh0 users invite <EMAIL> [--password <PASSWORD>] [--role <ROLE>] [--display-name <DISPLAY_NAME>]
# Update a user
sh0 users update <ID> [--role <ROLE>] [--display-name <DISPLAY_NAME>]
# Remove a user
sh0 users remove <ID> [--yes]
# Reset a user's password locally (recovery path; run on the server box, no login required)
sh0 users reset-password <EMAIL> [--password <PASSWORD>] [--disable-2fa] [--data-dir <DATA_DIR>] [--db <DB>]

sh0 projects

sh0 projects --help
# List all projects
sh0 projects list [--json]
# Create a new project
sh0 projects create <NAME> [--description <DESCRIPTION>] [--color <COLOR>]
# Delete an empty project (refused while it still holds apps, databases or services)
sh0 projects delete <PROJECT> [--yes]
# List project members
sh0 projects members <PROJECT> [--json]
# Add a member to a project
sh0 projects add-member <PROJECT> <USER> [--role <ROLE>]
# Remove a member from a project
sh0 projects remove-member <PROJECT> <USER>

sh0 update

sh0 update --help
# Update sh0, or roll back to the previous version
sh0 update [--rollback] [--channel <CHANNEL>] [--force] [--yes]

sh0 doctor

sh0 doctor --help
# Préflight d'hôte : Docker, ports, disque, certificats, horloge.
sh0 doctor [COMMAND] [--json] [--db <DB>] [--data-dir <DATA_DIR>] [--caddy-data <CADDY_DATA>] [--port <PORT>]
# Count restore rows that migration 055 could not reach (ISSUE-086).
sh0 doctor backup-rows [--json] [--db <DB>]
# List host mounts that the bind whitelist would refuse today (ISSUE-176).
sh0 doctor bind-mounts [--json] [--db <DB>] [--all]

sh0 instance

sh0 instance --help
# Écrire un instantané de cette instance dans un fichier
sh0 instance backup [--data-dir <DATA_DIR>] [--out <OUT>] [--encrypt]
# Reposer une instance sauvegardée sur cette machine
sh0 instance restore --file <FILE> [--data-dir <DATA_DIR>] [--dry-run] [--force]
# Remplacer la clé maîtresse et rechiffrer tous les secrets de la base
sh0 instance rotate-key [--data-dir <DATA_DIR>] [--dry-run] [--yes] [--backup-out <BACKUP_OUT>]

sh0 uninstall

sh0 uninstall --help
# Uninstall sh0 (remove binary and optionally data)
sh0 uninstall [--purge]

sh0 destroy

sh0 destroy --help
# Destroy everything: stop and remove all containers, images, volumes, networks, data, and binary
sh0 destroy