Close Lua plugins on reload

This commit is contained in:
Simon Ser 2020-01-10 17:00:34 +01:00
parent 171da51289
commit b014c1898f
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -18,8 +18,9 @@ type Server struct {
e *echo.Echo
Sessions *SessionManager
mutex sync.RWMutex // used for server reload
plugins []Plugin
mutex sync.RWMutex // used for server reload
plugins []Plugin
luaPlugins []Plugin
imap struct {
host string
@ -98,7 +99,15 @@ func (s *Server) load() error {
s.mutex.Lock()
defer s.mutex.Unlock()
// Close previous Lua plugins
for _, p := range s.luaPlugins {
if err := p.Close(); err != nil {
s.e.Logger.Printf("Failed to unload plugin '%v': %v", p.Name(), err)
}
}
s.plugins = plugins
s.luaPlugins = luaPlugins
s.e.Renderer = renderer
for _, p := range plugins {