Skip to main content

Module ctl

Module ctl 

Source
Expand description

rws ctl / rwsctl: the admin API from the command line (18.20.0). rws ctl (18.20.0, #70): the admin API from the command line.

rws ctl status                         # version, uptime, listeners, disks
rws ctl reload                         # waits; prints the errors and exits 1 on a bad config
rws ctl drain <upstream> <backend> [--undo]
rws ctl maintenance [on|off]
rws ctl block <ip> | unblock <ip> | blocklist
rws ctl purge <cache> [--path /p | --prefix /p/]
rws ctl caches | upstreams
rws ctl certs [renew]
rws ctl logs [-n 100] [-f]
rws ctl traffic [--week | --month | --hours N] [--host example.com]
rws ctl whoami                         # the token's user and role (18.22.0)
rws ctl audit [-n 50]                  # recent changes: who, what, when (18.22.0)

The binary run as rwsctl (the packages install that symlink) acts as rws ctl. Where it connects: --admin http://127.0.0.1:9901, else [admin] listen of RWS_CONFIG_FILE / rws.config.toml, else 127.0.0.1:9901. The token: --token-file, else the variable [admin] token_env names, else RWS_ADMIN_TOKEN — never an argument, so it can’t show in ps. Output is for people; --json prints the API’s JSON. Exit codes: 0 done, 1 refused or failed, 2 usage error, admin API unreachable or token refused.

Constants§

EXIT_FAILED
The server refused or the operation failed.
EXIT_OK
Done.
EXIT_UNUSABLE
Bad arguments, the admin API unreachable, or the token refused.

Functions§

invoked_as_rwsctl
Whether the program was started as rwsctl (its file name, any extension).
requested
The rws ctl arguments in args (a full argv): after ctl, or all of them when run as rwsctl. None for a normal server start.
run
Run rws ctl <args>, writing to out and err; returns the exit code.