Skip to content

Run golang app as background program, 以后台形式运行golang

License

Notifications You must be signed in to change notification settings

zhaoyun006/godaemon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godaemon

Run golang app as background program, 以后台形式运行golang

安装:

go get github.com/CodyGuo/godaemon

示例:

package main

import (
	_ "github.com/CodyGuo/godaemon"
	"log"
	"net/http"
)

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/index", func(rw http.ResponseWriter, req *http.Request) {
		rw.Write([]byte("hello, golang!\n"))
	})
	log.Fatalln(http.ListenAndServe(":7070", mux))
}

运行

./example -d=true or ./example -d true
~$ curl http://127.0.0.1:7070/index
hello, golang!

About

Run golang app as background program, 以后台形式运行golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%