server: Add some comments and clean up a bit -- from jlatt/ergonomadic#39 <3

This commit is contained in:
Daniel Oaks 2016-08-14 14:13:01 +10:00
parent 43553390d6
commit a177ca36b1
1 changed files with 11 additions and 2 deletions

View File

@ -46,8 +46,12 @@ type Server struct {
}
var (
SERVER_SIGNALS = []os.Signal{syscall.SIGINT, syscall.SIGHUP,
syscall.SIGTERM, syscall.SIGQUIT}
SERVER_SIGNALS = []os.Signal{
syscall.SIGINT,
syscall.SIGHUP, // eventually we expect to use HUP to reload config
syscall.SIGTERM,
syscall.SIGQUIT,
}
)
type clientConn struct {
@ -113,6 +117,7 @@ func NewServer(config *Config) *Server {
server.wslisten(config.Server.Wslisten, config.Server.TLSListeners)
}
// Attempt to clean up when receiving these signals.
signal.Notify(server.signals, SERVER_SIGNALS...)
// add RPL_ISUPPORT tokens
@ -181,6 +186,10 @@ func (server *Server) Shutdown() {
for _, client := range server.clients.byNick {
client.Notice("Server is shutting down")
}
if err := server.db.Close(); err != nil {
Log.error.Println("Server.Shutdown: error:", err)
}
}
func (server *Server) Run() {