mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
2a6ade0fe4
* feat: add /reload to gateway api and command * prevent duplicate reload request in same time
21 lines
523 B
Go
21 lines
523 B
Go
package commands
|
|
|
|
import "context"
|
|
|
|
func reloadCommand() Definition {
|
|
return Definition{
|
|
Name: "reload",
|
|
Description: "Reload the configuration file",
|
|
Usage: "/reload",
|
|
Handler: func(_ context.Context, req Request, rt *Runtime) error {
|
|
if rt == nil || rt.ReloadConfig == nil {
|
|
return req.Reply(unavailableMsg)
|
|
}
|
|
if err := rt.ReloadConfig(); err != nil {
|
|
return req.Reply("Failed to reload configuration: " + err.Error())
|
|
}
|
|
return req.Reply("Config reload triggered!")
|
|
},
|
|
}
|
|
}
|