application

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2017 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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, logging, putting process in the background aka daemonizing and starting arbitrary functions that provide core logic.

func NewApp

func NewApp(name string, o Options) (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() 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 Options

type Options struct {
	// Working directory after daemonizing.
	HomeDir string
	// Directory for log files. If it is not set, logging will be configured
	// to print messages to stderr.
	LogDir string
	// Log files mode.
	LogFileMode os.FileMode
	// Log directories mode.
	LogDirectoryMode os.FileMode
	// LogLevel is the lowest level of log messages that will be logged.
	LogLevel logging.Level
	// Syslog facility for syslog messages. If it is not set, no logging to
	// syslog will be done.
	SyslogFacility logging.SyslogFacility
	// Syslog tag for sysylog messages.
	SyslogTag string
	// Syslog named network.
	SyslogNetwork string
	// Syslog network address.
	SyslogAddress string
	// AccessLogLevel is the lowest level of HTTP access log messages that will
	// be logged.
	AccessLogLevel logging.Level
	// Syslog facility for syslog messages of HTTP requests. If it is not set,
	// no logging to syslog will be done.
	AccessSyslogFacility logging.SyslogFacility
	// Syslog tag for sysylog messages of HTTP requests.
	AccessSyslogTag string
	// PackageAccessLogLevel is the lowest level of HTTP access log messages
	// that will be logged for package resolutions.
	PackageAccessLogLevel logging.Level
	// Syslog facility for syslog messages of package resolution requests.
	// If it is not set, no logging to syslog will be done.
	PackageAccessSyslogFacility logging.SyslogFacility
	// Syslog tag for sysylog messages of package resolution requests.
	PackageAccessSyslogTag string
	// Is logging of audit messages completely disabled.
	AuditLogDisabled bool
	// Syslog facility for syslog audit messages. If it is not set,
	// no logging to syslog will be done.
	AuditSyslogFacility logging.SyslogFacility
	// Syslog tag for sysylog audit messages.
	AuditSyslogTag string
	// If LogDir is set, but there is need to force logging to stderr,
	// ForceLogToStderr should be set to true.
	ForceLogToStderr bool
	// 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
}

Options contain optional parameters for App.

Jump to

Keyboard shortcuts

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