daemon

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 4 Imported by: 1

README

daemon

Go demonization library. It's sevlyar/go-daemon wrapper.

Summary

  • Easy to use
  • MIT license
  • sevlyar/go-daemon wrapper

Install

go get github.com/wmentor/daemon

Usage

package main

import (
  "github.com/wmentor/daemon"
)

func main() {

  config := "pid=/var/run/main.pid dir=/dir log=/var/log/myapp.log"
  if err := daemon.Run(config); err != nil {
    panic("daemon didn't run")
  }

  // your code 
}

You must call daemon.Run before exclusive usage of resources (bind ports, open files for write).

Any of the parameters (pid, log, dir) can be deleted from dsn string.

package main

import (
  "github.com/wmentor/daemon"
)

func main() {

  // no pid and no log
  if err := daemon.Run(""); err != nil {
    panic("daemon didn't run")
  }

  // your code 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(dsn string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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