Skip to content

CLI Reference

Syntax

sweety [OPTIONS] [COMMAND]

Global Options

OptionShortDefaultDescription
--config <PATH>-cconfig/sweety.tomlConfig file path
--pid-file <PATH>/var/run/sweety.pidPID file path (daemon mode)
--version-vShow version

Environment variable SWEETY_CONFIG can replace -c:

bash
SWEETY_CONFIG=/etc/sweety/sweety.toml sweety run

Subcommands

run — Foreground

Run in foreground, recommended under systemd / supervisord:

bash
sweety run
sweety run -c /etc/sweety/sweety.toml
  • Logs output to stdout/stderr
  • Graceful shutdown on SIGTERM / SIGINT (waits for existing connections)
  • Default subcommand when omitted

start — Background (Daemon)

Start in background, writes PID file:

bash
sweety start
sweety start -c /etc/sweety/sweety.toml --pid-file /var/run/sweety.pid

stop — Stop Background Process

Reads PID file, sends SIGTERM:

bash
sweety stop
sweety stop --pid-file /var/run/sweety.pid

restart — Restart

Equivalent to stop + start:

bash
sweety restart
sweety restart -c /etc/sweety/sweety.toml

reload — Hot Reload Config

Reload config without dropping existing connections:

bash
sweety reload
sweety reload -c /etc/sweety/sweety.toml

Prerequisite: global.admin_listen must be configured — reload sends a signal via the Admin API.

toml
[global]
admin_listen = "127.0.0.1:9099"

Hot reload scope:

  • ✅ Site config (server_name, root, locations, etc.)
  • ✅ Rate limiting, cache config
  • ✅ Upstream node list
  • ⚠️ Listen port changes require restart

validate — Validate Config

Equivalent to nginx -t, checks config syntax and TLS certificates:

bash
sweety validate
sweety validate -c /etc/sweety/sweety.toml

Checks:

  • TOML/JSON/YAML syntax validity
  • Required fields (name, server_name)
  • TLS certificate and key file paths are readable
  • Upstream node format correctness
  • Port conflict detection

Success output:

Configuration check passed ✓
  Sites: 3
  Listen ports: 80, 443
  TLS sites: 2 (ACME: 1, Manual: 1)

version — Show Version

bash
sweety version
# or
sweety -v

api-doc — Output Admin API Docs

Output Admin REST API documentation (OpenAPI format):

bash
sweety api-doc
sweety api-doc > api-doc.json

Admin API

After configuring admin_listen, Sweety provides a REST API:

toml
[global]
admin_listen = "127.0.0.1:9099"
admin_token  = "your-secret-token"

Authentication

Endpoints requiring auth must include a Bearer Token:

bash
curl -H "Authorization: Bearer your-secret-token" http://127.0.0.1:9099/api/v1/stats

Endpoints

MethodPathAuthStatusDescription
GET/api/v1/healthNoHealth check
GET/api/v1/versionNoVersion info
GET/api/v1/statsYesGlobal request statistics snapshot
GET/api/v1/pluginsYesRegistered plugin list
GET/api/v1/docNoAPI documentation (JSON)
GET/api/v1/sitesYes⚠️ StubSite list (full in v0.5)
POST/api/v1/reloadYes🚧 PlannedHot reload (v0.5)
GET/api/v1/upstreamsYes🚧 PlannedUpstream nodes & circuit breaker status (v0.5)
POST/api/v1/upstreams/:name/nodes/:addr/enableYes🚧 PlannedEnable node (v0.5)
POST/api/v1/upstreams/:name/nodes/:addr/disableYes🚧 PlannedDisable node (v0.5)
WebSocket /api/v1/stats/stream🚧 PlannedReal-time stats push (v0.5)
GET/metrics🚧 PlannedPrometheus metrics endpoint (v0.5)

⚠️ sweety reload currently uses system signals for hot reload, not the Admin API. POST /api/v1/reload is not yet implemented.


Common Operations

bash
# Install as systemd service (foreground mode, recommended)
sudo systemctl start sweety

# Reload config (no service interruption)
sweety reload -c /etc/sweety/sweety.toml

# Test config then restart
sweety validate -c /etc/sweety/sweety.toml && sweety restart -c /etc/sweety/sweety.toml

Released under the Apache License 2.0