daemonigo

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2015 License: MIT Imports: 10 Imported by: 20

README

daemonigo

A simple library to daemonize Go programming language applications.

Installing

$ go get github.com/tyranron/daemonigo

After this command daemonigo is ready to use.

Usage

Usage examples you can see in examples/ repository directory.

Documentation

See http://godoc.org/github.com/tyranron/daemonigo

Or run:

$ godoc github.com/tyranron/daemonigo

License

MIT License

Documentation

Overview

Package daemonigo provides a simple wrapper to daemonize applications.

Index

Constants

This section is empty.

Variables

View Source
var AppName = "daemon"

Application name to daemonize. Used for printing in default daemon actions.

View Source
var AppPath = "./" + filepath.Base(os.Args[0])

Path to application executable. Used only for default start/restart actions.

View Source
var EnvVarName = "_DAEMONIGO"

Name of environment variable used to distinguish parent and daemonized processes.

View Source
var EnvVarValue = "1"

Value of environment variable used to distinguish parent and daemonized processes.

View Source
var PidFile = "daemon.pid"

Absolute or relative path from working directory to PID file.

View Source
var PidFileMask os.FileMode = 0644

Value of file mask for PID-file.

View Source
var Umask = 027

Value of umask for daemonized process.

View Source
var WorkDir = ""

Path to daemon working directory. If not set, the current user directory will be used.

Functions

func Daemonize

func Daemonize() (isDaemon bool, err error)

This function wraps application with daemonization. Returns isDaemon value to distinguish parent and daemonized processes.

func RemoveAction

func RemoveAction(name string)

Removes daemon action with given name.

This function is not concurrent safe, so you must synchronize its calls in case of usage in multiple goroutines.

func SetAction

func SetAction(name string, action func())

Sets new daemon action with given name or overrides previous.

This function is not concurrent safe, so you must synchronize its calls in case of usage in multiple goroutines.

func Start

func Start(timeout uint8) (e error)

Starts daemon process and waits timeout number of seconds. If daemonized process keeps running after timeout seconds passed then process seems to be successfully started.

This function can also be used when writing your own daemon actions.

func StartCommand added in v0.3.0

func StartCommand() (*exec.Cmd, error)

Prepares and returns command for starting daemonized process.

This function can also be used when writing your own daemon actions.

func Status

func Status() (isRunning bool, pr *os.Process, e error)

Checks status of daemonized process. Can be used in daemon actions to perate with daemonized process.

func Stop

func Stop(process *os.Process) (e error)

Stops daemon process. Sends signal os.Interrupt to daemonized process.

This function can also be used when writing your own daemon actions.

func UnlockPidFile

func UnlockPidFile()

Unlocks PID file (locked by current daemonized process) and closes this file.

This function can be useful for graceful restarts or other untrivial scenarios, but usually there is no need to use it.

Types

This section is empty.

Directories

Path Synopsis
examples
echo_server
A simple echo server implementation from net.Listener official documentation.
A simple echo server implementation from net.Listener official documentation.
graceful_http
An example of graceful HTTP server with zero-downtime reload.
An example of graceful HTTP server with zero-downtime reload.
notify_parent
An example of simple "Hello, World!" HTTP server with bulletproof starting.
An example of simple "Hello, World!" HTTP server with bulletproof starting.

Jump to

Keyboard shortcuts

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