Documentation
¶
Overview ¶
Package cmd implements the commands: warm, list, debug and version.
Each command takes the injected runtime and its own arguments and returns an exit status. Nothing here reads os.* or flag.CommandLine: main hands everything over.
Index ¶
- Constants
- func Debug(ctx context.Context, rt *Runtime, args []string) int
- func List(ctx context.Context, rt *Runtime, args []string) int
- func NewLogger(stderr io.Writer, verbosity int) *slog.Logger
- func RealMain(ctx context.Context, args, env []string, stdin io.Reader, ...) int
- func Version(rt *Runtime) int
- func Warm(ctx context.Context, rt *Runtime, args []string) int
- type OSFS
- type Runtime
Constants ¶
const ( // ExitOK reports that every listed URL answered 2xx in the last run. ExitOK = 0 // ExitFailed reports a last run where a URL failed, was redirected without // --follow or was out of scope without --lax, or an empty enumeration. ExitFailed = 1 // ExitUsage reports a bad command line, or a source that did not answer 200. ExitUsage = 2 // ExitLogin reports a Drupal login the site did not accept. ExitLogin = 3 )
Exit statuses. They hold for the binary: go run collapses every non-zero status to 1.
const ( EnvBasicAuthPassword = "DRUPAL_WARMUP_BAPASS" EnvDrupalPassword = "DRUPAL_WARMUP_DRPASS" )
Environment variables standing in for the password flags, which are visible to ps and land in shell history.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
Debug fetches the given URLs one at a time with the Xdebug trigger set.
A production warm never carries a debug trigger, which is why this is a command of its own rather than a flag on warm. Redirects are never followed, and stdout shows the status line, the response headers and the drained body length of each answer.
func List ¶
List enumerates the site and prints one URL per line, fetching none.
An entry the warm command would skip is printed behind a # with its reason, which the list-file source ignores, so the output feeds a later run unchanged.
func NewLogger ¶
NewLogger maps the verbosity to a level: 0 is silent, 1 warnings, 2 progress, 3 requests.
func RealMain ¶
func RealMain(ctx context.Context, args, env []string, stdin io.Reader, stdout, stderr io.Writer, fsys fs.FS, transport http.RoundTripper, ) int
RealMain is the composition root: it takes every ambient value the program reads.
It parses the global flags, builds the logger and dispatches on the command.