application

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: BSD-3-Clause Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFileMode          os.FileMode = 0666
	DefaultDirectoryMode     os.FileMode = 0777
	DefaultDaemonLogFileName             = "daemon.log"
)

Package default variables.

View Source
var NewConfig = config.New

NewConfig creates a new instance of Config.

Deprecated: Use resenje.org/x/config.New.

Functions

func StopDaemon

func StopDaemon(d daemon.Daemon) error

StopDaemon send term signal to a daemonized process and reports the status.

Types

type App

type App struct {

	// A list of non-blocking or short-lived functions to be executed on
	// App.Start.
	Functions []func() error
	// A function to be executed after receiving SIGINT or SIGTERM.
	ShutdownFunc func() error
	// Instance of resenje.org/daemon.Daemon.
	Daemon *daemon.Daemon
	// contains filtered or unexported fields
}

App provides common functionalities of an application, like setting a working directory and putting process in the background aka daemonizing and starting arbitrary functions that provide core logic.

func NewApp

func NewApp(name string, o AppOptions) (a *App, err error)

NewApp creates a new instance of App, based on provided Options.

func (App) Daemonize

func (a App) Daemonize()

Daemonize puts process in the background.

func (App) Start

func (a App) Start(logger *slog.Logger) error

Start executes all function in App.Functions, starts a goroutine that receives USR1 signal to dump debug data and blocks until INT or TERM signals are received.

type AppOptions

type AppOptions struct {
	// Working directory after daemonizing.
	HomeDir string
	// Directory for log files. If it is not set, logger will be configured
	// to print messages to stderr.
	LogDir string
	// File name of a PID file.
	PidFileName string
	// Mode of a PID file. Default 644.
	PidFileMode os.FileMode
	// File name in which to redirect stdout and stderr of a daemonized process.
	// If it is not set, /dev/null will be used.
	DaemonLogFileName string
	// Mode of a daemon log file. Default 644.
	DaemonLogFileMode os.FileMode
}

AppOptions contain optional parameters for App.

type Config deprecated

type Config = config.Config

Config holds the common information for options: name and directories from where to load values.

Deprecated: Use resenje.org/x/config.Config.

type EmailOptions

type EmailOptions struct {
	NotifyAddresses []string `json:"notify-addresses" yaml:"notify-addresses" envconfig:"NOTIFY_ADDRESS"`
	DefaultFrom     string   `json:"default-from" yaml:"default-from" envconfig:"DEFAULT_FROM"`
	SubjectPrefix   string   `json:"subject-prefix" yaml:"subject-prefix" envconfig:"SUBJECT_PREFIX"`
	SMTPIdentity    string   `json:"smtp-identity" yaml:"smtp-identity" envconfig:"SMTP_IDENTITY"`
	SMTPUsername    string   `json:"smtp-username" yaml:"smtp-username" envconfig:"SMTP_USERNAME"`
	SMTPPassword    string   `json:"smtp-password" yaml:"smtp-password" envconfig:"SMTP_PASSWORD"`
	SMTPHost        string   `json:"smtp-host" yaml:"smtp-host" envconfig:"SMTP_HOST"`
	SMTPPort        int      `json:"smtp-port" yaml:"smtp-port" envconfig:"SMTP_PORT"`
	SMTPSkipVerify  bool     `json:"smtp-skip-verify" yaml:"smtp-skip-verify" envconfig:"SMTP_SKIP_VERIFY"`
	// contains filtered or unexported fields
}

EmailOptions defines parameters for email sending.

func NewEmailOptions

func NewEmailOptions(name string) *EmailOptions

NewEmailOptions initializes EmailOptions with default values.

func (*EmailOptions) VerifyAndPrepare

func (o *EmailOptions) VerifyAndPrepare() error

VerifyAndPrepare implements application.Options interface.

type Options deprecated

type Options = config.Options

Options defines methods that are required for options.

Deprecated: Use resenje.org/x/config.Options.

Jump to

Keyboard shortcuts

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