godaemon

package module
v0.0.0-...-2dc1c88 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2014 License: BSD-3-Clause Imports: 7 Imported by: 1

README

godaemon

Simple Daemonize Helper Code

Exmaple

package main

import "github.com/miolini/godaemon"
import "time"
import "log"

func main() {
    pidFile := "/var/run/mydaemon.pid"
    err := godaemon.WritePidFile(pidFile)
    if err != nil {
        log.Fatalf("pid error: %s", err)
    }
    time.Sleep(5)
    godaemon.RemovePidFile(pidFile)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(label string, err error)

func NewStatCounter

func NewStatCounter(label string, interval int) chan int

func RemovePidFile

func RemovePidFile(filename string) (err error)

func WorkerAmqpConsumer

func WorkerAmqpConsumer(worker *Worker, uri string, queue string, msgChan chan string) (err error)

func WorkerAmqpPublisher

func WorkerAmqpPublisher(worker *Worker, uri string, exchange string, msgChan chan string, statChan chan int) (err error)

func WorkerStringFilter

func WorkerStringFilter(worker *Worker, inputChan chan string, outputChan chan string, fn func(string) (string, error)) (err error)

func WritePidFile

func WritePidFile(filename string) (pid int, err error)

Types

type Worker

type Worker struct {
	Label string
	Num   int
	Sleep time.Duration
	Func  func(*Worker) error
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(label string, num int, sleep time.Duration) (worker *Worker)

func (*Worker) Start

func (worker *Worker) Start(fn func(*Worker) error) *Worker

func (*Worker) Stop

func (worker *Worker) Stop()

func (*Worker) Wait

func (worker *Worker) Wait()

Jump to

Keyboard shortcuts

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