GoldenDaemon

package module
v0.0.0-...-0001c02 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2017 License: GPL-3.0 Imports: 3 Imported by: 3

README

GoldenDaemon

Run golang app as background program.

Install

go get github.com/Baozisoftware/GoldenDaemon

Example

package main

import (
	"github.com/Baozisoftware/GoldenDaemon"
	"flag"
	"net/http"
)

func main() {
	GoldenDaemon.RegisterTrigger("d", "-restarted")
	re := flag.Bool("restarted", false, "test")
	flag.Parse()
	mux := http.NewServeMux()
	mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
		data := []byte("Hello,世界!")
		if *re {
			data = append(data, []byte("\n(Restarted)")...)
		}
		rw.Write(data)
	})
	http.ListenAndServe(":8080", mux)
}

Precautions

  1. Avoid using loop output or get input code, otherwise it will make CPU occupancy high;
  2. For triggering parameters, do not need to add "-"

Screenshots

example.exe

normal

example.exe -d

restarted

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTrigger

func RegisterTrigger(key string, otherArgs ...string) error

func RestartSelf

func RestartSelf(otherArgs ...string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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