Skip to content

Instantly share code, notes, and snippets.

@sonots
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonots/87972440cd2063504902 to your computer and use it in GitHub Desktop.
Save sonots/87972440cd2063504902 to your computer and use it in GitHub Desktop.
//http.ListenAndServe(":8080", m)
proto := "unix"
addr := "/dev/shm/app.sock"
l, e := net.Listen(proto, addr)
if e != nil {
fmt.Println(e)
}
//as the daemon is launched as root, change to permission of the socket to allow non-root to connect
if proto == "unix" {
os.Chmod(addr, 0777)
}
httpSrv := http.Server{Addr: addr, Handler: m}
httpSrv.Serve(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment