- Notifications
You must be signed in to change notification settings - Fork0
Runlevel 1, you stay unix socket. Runlevel 3, you listen tcp! Kicks old process on boot. Shuts down when kicked by new process. Could contribute to less downtime between app restarts and upgrades.
License
aerth/diamond
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Diamond provides a UNIX socket for administrators to gracefully shutdown an application, such as a web server.
Apart from only shutting down, the admin can change gears, triggering functions and killing/starting listeners.
The "KICK" feature allows upgrading a program with minimal downtime, kicking the old running process gracefully.
If diamond-admin doesn't run on your platform (bsd?) you can still use the client library!
⚡telinit 3
You can open admin interface by using no arguments:
diamond-admin -s diamond.sock
diamond-admin -s diamond.sock RUNLEVEL 3
diamond-admin -s diamond.sock RUNLEVEL 1
Diamond requires a recent version of Go
// New creates a new admin socket and starts listening for commandss, err := diamond.New("/tmp/diamond.socket")if err != nil { log.Fatalln(err)}// Add variety of http handlers and their addr to listen on// They won't start listening right away, so they could be// occupied by other serverss.AddHTTPHandler(":8080", http.HandlerFunc(myHandler))s.AddHTTPHandler(":8081", http.HandlerFunc(handler2))s.AddHTTPHandler(":8082", handler3)// start in multiuser mode, serving http// without calling Runlevel(3) you must// connect via socket and issue the RUNLEVEL 3 commands.Runlevel(3) // serve foreverlog.Fatalln(s.Wait())
See theexamples
Read more:
API may change without notice! (it already has two times!)
Submit new issue or pull request
import "gopkg.in/aerth/diamond.v1"
About
Runlevel 1, you stay unix socket. Runlevel 3, you listen tcp! Kicks old process on boot. Shuts down when kicked by new process. Could contribute to less downtime between app restarts and upgrades.