daemon

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2019 License: BSD-3-Clause Imports: 9 Imported by: 4

README

Daemon for Go

Installation

Run go get resenje.org/daemon from command line.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

type Daemon struct {
	PidFileName string
	PidFileMode os.FileMode
}

Daemon is a structure that holds information about PID file.

func (*Daemon) Cleanup

func (d *Daemon) Cleanup() error

Cleanup removes PID file.

func (*Daemon) Daemonize

func (d *Daemon) Daemonize(workDir string, inFile io.Reader, outFile io.Writer, errFile io.Writer) error

Daemonize terminates the execution of the initial process and starts a new process in the background. If workDir is not zero length string, os.Chdir is executed with that value. New process will have standard input, output and error specified by inFile, outFile and errFile. PID file will be created with the second process ID.

func (*Daemon) Pid

func (d *Daemon) Pid() (int, error)

Pid returns process ID if available.

func (*Daemon) Process

func (d *Daemon) Process() (*os.Process, error)

Process returns an os.Process and error returned by os.FindProcess based on the content from PID file.

func (*Daemon) Signal

func (d *Daemon) Signal(sig os.Signal) error

Signal sends os.Signal to the daemonized process.

func (*Daemon) Status

func (d *Daemon) Status() (pid int, err error)

Status returns PID as int of a daemonized process. If the process is not running, returned error is not nil.

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop sends SIGTERM signal to the daemonized process. If it fails, SIGKILL signal is sent.

Jump to

Keyboard shortcuts

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