nginx

package
v1.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

README

nginx plugin

The nginx plugin provides controls an nginx server, with the following operations:

  • Start and restart server
  • Reload server
  • Reopen files (for rotating the log files)
  • Test configuration without restarting the server
  • Enumeration of "available" configuration templates
  • Enabling of configurations with templating

The main use case is to provide a controllable nginx server in a Docker container, with an API which can be used to control the server. The plugin should be used with the following two additional plugins:

  • nginx-gateway: This plugin provides a REST API gateway to the nginx plugin, and can have authentication controls added.
  • nginx-client: Can be intergated into an API client, for control of nginx through a client application.

Documentation

Overview

The `nginx` task spawns an nginx server, and can test and reload the nginx configuration.

Index

Constants

View Source
const (
	ScopeRead  = "github.com/mutablelogic/go-server/nginx:read"
	ScopeWrite = "github.com/mutablelogic/go-server/nginx:write"
)

Variables

This section is empty.

Functions

func IsExecAny

func IsExecAny(mode os.FileMode) bool

IsExecAny returns true if the file mode is executable by any user

func NewWithPlugin

func NewWithPlugin(p Plugin, label string) (*t, error)

Create a new logger task with provider of other tasks

Types

type CallbackFn

type CallbackFn func(*Cmd, []byte)

Callback output from the command. Newlines are embedded within the string

type Cmd

type Cmd struct {
	Out, Err    CallbackFn
	Start, Stop time.Time
	// contains filtered or unexported fields
}

func NewWithCommand

func NewWithCommand(cmd string, args ...string) (*Cmd, error)

Create a new command with arguments

func (*Cmd) Exited

func (c *Cmd) Exited() bool

Return whether command has exited

func (*Cmd) Path added in v1.1.3

func (c *Cmd) Path() string

Path returns the path of the executable

func (*Cmd) Pid

func (c *Cmd) Pid() int

Return the pid of the process or 0

func (*Cmd) Run

func (c *Cmd) Run() error

Run the command in the foreground, and return any errors

func (*Cmd) SetArgs added in v1.1.3

func (c *Cmd) SetArgs(args ...string)

SetArgs appends arguments for the command

func (*Cmd) SetEnv added in v1.1.3

func (c *Cmd) SetEnv(env map[string]string) error

SetEnv appends the environment variables for the command

func (*Cmd) Signal

func (c *Cmd) Signal(s os.Signal) error

Send signal to the process

func (*Cmd) String

func (t *Cmd) String() string

type Config

type Config struct {
	sync.RWMutex

	// Configuration Files
	Files map[string]*File
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(available, enabled string) (*Config, error)

func (*Config) Available

func (c *Config) Available() []string

Return a list of files which are available to be enabled

func (*Config) Enable

func (c *Config) Enable(key string, args ...any) error

func (*Config) String

func (c *Config) String() string

Return a list of files which are available to be enabled

type Event

type Event uint
const (
	EventStart Event = iota
	EventStop
	EventReload
	EventInfo
	EventError
)

func (Event) String

func (e Event) String() string

type File

type File struct {
	// Path to the file
	Path string

	// Info for the file
	Info fs.FileInfo

	// Enabled indicates the configuration file is enabled
	Enabled bool
}

func (*File) AvailableBase

func (f *File) AvailableBase() string

Return the "enabled" name of the file

func (*File) EnabledBase

func (f *File) EnabledBase() string

Return the "enabled" name of the file

func (*File) Ext

func (f *File) Ext() string

Return the file extension

func (*File) Hash

func (f *File) Hash() string

Return the hash of the filename

func (*File) Name

func (f *File) Name() string

Return the last element of the path by name

func (*File) String

func (f *File) String() string

type HealthResponse added in v1.1.3

type HealthResponse struct {
	Version string `json:"version"`
	Uptime  uint64 `json:"uptime_secs"`
}

type Plugin

type Plugin struct {
	task.Plugin
	Path_      types.String            `json:"path,omitempty"`      // Path to the nginx binary
	Config_    types.String            `json:"config,omitempty"`    // Path to the configuration file
	Prefix_    types.String            `json:"prefix,omitempty"`    // Prefix for nginx configuration
	Available_ types.String            `json:"available,omitempty"` // Path to available configurations
	Enabled_   types.String            `json:"enabled,omitempty"`   // Path to enabled configurations
	Env_       map[string]types.String `json:"env,omitempty"`       // Environment variable map
	Directive_ map[string]types.String `json:"directive,omitempty"` // Directive map
}

func (Plugin) Available

func (p Plugin) Available() string

func (Plugin) Config

func (p Plugin) Config() string

func (Plugin) Enabled

func (p Plugin) Enabled() string

func (Plugin) Env

func (p Plugin) Env() map[string]string

func (Plugin) Flags

func (p Plugin) Flags() []string

func (Plugin) Name

func (p Plugin) Name() string

func (Plugin) New

func (p Plugin) New(parent context.Context, provider iface.Provider) (iface.Task, error)

Create a new logger task with provider of other tasks

func (Plugin) Path

func (p Plugin) Path() string

func (Plugin) Prefix

func (p Plugin) Prefix() string

Directories

Path Synopsis
nginx.client package is the REST API client for the nginx gateway.
nginx.client package is the REST API client for the nginx gateway.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL