Skip to content

Iwark/godaemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

godaemon

godaemon is a simple Go(golang) daemon package.

Installation

$ go get -u github.com/Iwark/godaemon

Example

package main

import (
  "flag"
  "log"

  "github.com/Iwark/godaemon"
)

var (
  child   = flag.Bool("child", false, "Run as a child process")
  logfile = flag.String("l", "logfile.log", "log file")
)

func main() {

  flag.Parse()
  if err := godaemon.Start(*child); err != nil {
    log.Fatal(err)
    return
  }
  f, err := godaemon.OutputFile(*logfile)
  if err != nil {
    log.Fatal(err)
    return
  }
  defer f.Close()
  log.SetOutput(f)

  // anything to do ...
}

About

A simple Go(golang) daemon package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages