3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-26 05:49:25 +01:00

make it clearer when rehash has completed

This commit is contained in:
Shivaram Lingamneni 2020-05-18 11:25:49 -04:00
parent c7aa337ed7
commit b494c1ec35
2 changed files with 15 additions and 11 deletions

View File

@ -2238,14 +2238,18 @@ func quitHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
// REHASH
func rehashHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
server.logger.Info("server", fmt.Sprintf("REHASH command used by %s", client.nick))
nick := client.Nick()
server.logger.Info("server", "REHASH command used by", nick)
err := server.rehash()
if err == nil {
rb.Add(nil, server.name, RPL_REHASHING, client.nick, "ircd.yaml", client.t("Rehashing"))
// we used to send RPL_REHASHING here but i don't think it really makes sense
// in the labeled-response world, since the intent is "rehash in progress" but
// it won't display until the rehash is actually complete
// TODO all operators should get a notice of some kind here
rb.Notice(client.t("Rehash complete"))
} else {
server.logger.Error("server", fmt.Sprintln("Failed to rehash:", err.Error()))
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REHASH", err.Error())
rb.Add(nil, server.name, ERR_UNKNOWNERROR, nick, "REHASH", err.Error())
}
return false
}

View File

@ -141,10 +141,7 @@ func (server *Server) Run() {
case <-server.rehashSignal:
go func() {
server.logger.Info("server", "Rehashing due to SIGHUP")
err := server.rehash()
if err != nil {
server.logger.Error("server", fmt.Sprintln("Failed to rehash:", err.Error()))
}
server.rehash()
}()
}
}
@ -451,7 +448,7 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
// rehash reloads the config and applies the changes from the config file.
func (server *Server) rehash() error {
server.logger.Debug("server", "Starting rehash")
server.logger.Info("server", "Starting rehash")
// only let one REHASH go on at a time
server.rehashMutex.Lock()
@ -461,14 +458,17 @@ func (server *Server) rehash() error {
config, err := LoadConfig(server.configFilename)
if err != nil {
return fmt.Errorf("Error loading config file config: %s", err.Error())
server.logger.Error("server", "failed to load config file", err.Error())
return err
}
err = server.applyConfig(config)
if err != nil {
return fmt.Errorf("Error applying config changes: %s", err.Error())
server.logger.Error("server", "Failed to rehash", err.Error())
return err
}
server.logger.Info("server", "Rehash completed successfully")
return nil
}