Hot Reload
Hot reload allows reloading the configuration file without dropping existing connections, equivalent to nginx -s reload.
Prerequisites
Admin API listen address must be configured:
toml
[global]
admin_listen = "127.0.0.1:9099"
admin_token = "your-secret-token" # Optional, recommended for productionTrigger Hot Reload
bash
sweety reload
sweety reload -c /etc/sweety/sweety.tomlEquivalent API call:
bash
curl -X POST \
-H "Authorization: Bearer your-secret-token" \
http://127.0.0.1:9099/api/reloadHot Reload Scope
| Config Item | Hot Reload Support |
|---|---|
Site server_name / root / index | ✅ |
[[sites.locations]] routing rules | ✅ |
[[sites.upstreams]] upstream nodes | ✅ |
[sites.fastcgi] FastCGI config | ✅ |
[sites.rate_limit] rate limit rules | ✅ |
[sites.proxy_cache] cache config | ✅ |
[global] log level | ✅ |
Listen ports (listen / listen_tls) | ⚠️ Requires restart |
| TLS certificate file paths | ⚠️ Requires restart |
[global] worker_threads | ⚠️ Requires restart |
systemd Integration
Configure ExecReload in the systemd unit file so systemctl reload sweety triggers hot reload:
ini
[Service]
ExecStart = /usr/local/bin/sweety run -c /etc/sweety/sweety.toml
ExecReload = /usr/local/bin/sweety reload -c /etc/sweety/sweety.tomlbash
# Reload config (no connection drops)
sudo systemctl reload sweety
# Full restart (drops all connections)
sudo systemctl restart sweetyConfig Change Workflow
bash
# 1. Edit config
vim /etc/sweety/sweety.toml
# 2. Validate syntax
sweety validate -c /etc/sweety/sweety.toml
# 3. Hot reload (zero downtime)
sweety reload -c /etc/sweety/sweety.toml
# Or one step
sweety validate -c /etc/sweety/sweety.toml && sweety reload -c /etc/sweety/sweety.tomlMonitor Reload Results
After reload, confirm the config has been updated via the API:
bash
curl -H "Authorization: Bearer your-secret-token" \
http://127.0.0.1:9099/api/statusThe logs will show:
INFO sweety::config::hot_reload: Config hot reload complete, sites: 3