Back to godoc.org
github.com/abiosoft/caddy-exec

Package command

v0.0.0-...-8d34c54
Latest Go to latest

The latest major version is .

Published: Sep 5, 2020 | License: Apache-2.0 | Module: github.com/abiosoft/caddy-exec

Index

type App

type App struct {
	Commands []Cmd `json:"commands,omitempty"`
	// contains filtered or unexported fields
}

App is top level module that runs shell commands.

func (App) CaddyModule

func (a App) CaddyModule() caddy.ModuleInfo

CaddyModule implements caddy.ModuleInfo

func (*App) Provision

func (a *App) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner

func (App) Start

func (a App) Start() error

Start starts the app.

func (*App) Stop

func (a *App) Stop() error

Stop stops the app.

func (App) Validate

func (a App) Validate() error

Validate implements caddy.Validator

type Cmd

type Cmd struct {
	// The command to run.
	Command string `json:"command,omitempty"`

	// The command args.
	Args []string `json:"args,omitempty"`

	// The directory to run the command from.
	// Defaults to current directory.
	Directory string `json:"directory,omitempty"`

	// If the command should run in the foreground.
	// By default, commands run in the background and doesn't
	// affect Caddy.
	// Setting this makes the command run in the foreground.
	// Note that failure of a startup command running in the
	// foreground may prevent Caddy from starting.
	Foreground bool `json:"foreground,omitempty"`

	// Timeout for the command. The command will be killed
	// after timeout has elapsed if it is still running.
	// Defaults to 10s.
	Timeout string `json:"timeout,omitempty"`

	// When the command should run. This can contain either of
	// "startup" or "shutdown".
	At []string `json:"at,omitempty"`
	// contains filtered or unexported fields
}

Cmd is the module configuration

func (*Cmd) UnmarshalCaddyfile

func (m *Cmd) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile configures the global directive from Caddyfile. Syntax:

exec [<matcher>] [<command> [<args...>]] {
    command     <text>
    args        <text>...
    directory   <text>
    timeout     <duration>
    foreground
    startup
    shutdown
}

type Middleware

type Middleware struct {
	Cmd
}

Middleware implements an HTTP handler that runs shell command.

func (Middleware) CaddyModule

func (Middleware) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Middleware) Cleanup

func (m *Middleware) Cleanup() error

Cleanup implements caddy.Cleanup TODO: ensure all running processes are terminated.

func (*Middleware) Provision

func (m *Middleware) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner.

func (Middleware) ServeHTTP

func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP implements caddyhttp.MiddlewareHandler.

func (Middleware) Validate

func (m Middleware) Validate() error

Validate implements caddy.Validator

type NoOpMatcher

type NoOpMatcher struct {
	Label string `json:"label,omitempty"`
	// contains filtered or unexported fields
}

NoOpMatcher is a matcher that blocks all requests. It's primary purpose is to ensure the command is not executed when no route/matcher is specified. Limitation of Caddyfile config. JSON/API config do not need this.

func (NoOpMatcher) CaddyModule

func (NoOpMatcher) CaddyModule() caddy.ModuleInfo

CaddyModule implements caddy.Module

func (NoOpMatcher) Match

func (m NoOpMatcher) Match(r *http.Request) bool

Match implements caddy.Matcher

func (*NoOpMatcher) Provision

func (m *NoOpMatcher) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner

type Runner

type Runner interface {
	Run() error
}

Runner runs a command.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier