Skip to content

Commit a177ca3

Browse files
committed
server: Add some comments and clean up a bit -- from jlatt/ergonomadic#39 <3
1 parent 4355339 commit a177ca3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

irc/server.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ type Server struct {
4646
}
4747

4848
var (
49-
SERVER_SIGNALS = []os.Signal{syscall.SIGINT, syscall.SIGHUP,
50-
syscall.SIGTERM, syscall.SIGQUIT}
49+
SERVER_SIGNALS = []os.Signal{
50+
syscall.SIGINT,
51+
syscall.SIGHUP, // eventually we expect to use HUP to reload config
52+
syscall.SIGTERM,
53+
syscall.SIGQUIT,
54+
}
5155
)
5256

5357
type clientConn struct {
@@ -113,6 +117,7 @@ func NewServer(config *Config) *Server {
113117
server.wslisten(config.Server.Wslisten, config.Server.TLSListeners)
114118
}
115119

120+
// Attempt to clean up when receiving these signals.
116121
signal.Notify(server.signals, SERVER_SIGNALS...)
117122

118123
// add RPL_ISUPPORT tokens
@@ -181,6 +186,10 @@ func (server *Server) Shutdown() {
181186
for _, client := range server.clients.byNick {
182187
client.Notice("Server is shutting down")
183188
}
189+
190+
if err := server.db.Close(); err != nil {
191+
Log.error.Println("Server.Shutdown: error:", err)
192+
}
184193
}
185194

186195
func (server *Server) Run() {

0 commit comments

Comments
 (0)