daemonize

package module
v0.0.0-...-e460293 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2016 License: Apache-2.0 Imports: 9 Imported by: 51

Documentation

Overview

Helper code for starting a daemon process.

This package assumes that the user invokes a tool, which invokes a daemon process. Though the tool starts the daemon process with stdin, stdout, and stderr closed (using Run), the daemon should be able to communicate status to the user while it starts up (using StatusWriter), causing the tool to exit in success or failure only when it is clear whether the daemon has sucessfully started (which it signal using SignalOutcome).

Index

Constants

This section is empty.

Variables

View Source
var StatusWriter io.Writer

For use by the daemon: the writer that should be used for logging status messages while in the process of starting up. The writer must not be written to after calling SignalOutcome.

Set to a reasonable default if the process wasn't invoked by a call to Run.

Functions

func Run

func Run(
	path string,
	args []string,
	env []string,
	status io.Writer) (err error)

Invoke the daemon with the supplied arguments, waiting until it successfully starts up or reports that is has failed. Write status updates while starting into the supplied writer (which may be nil for silence). Return nil only if it starts successfully.

func SignalOutcome

func SignalOutcome(outcome error) (err error)

For use by the daemon: signal an outcome back to Run in the invoking tool, causing it to return. Do nothing if the process wasn't invoked with Run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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