Software /
code /
prosody
Comparison
core/modulemanager.lua @ 9867:984f27e4b8a3
modulemanager: Set module status on successful or failed module load
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 19 Mar 2019 09:05:15 +0000 |
parent | 9563:732314eb3258 |
child | 10250:1006739de449 |
comparison
equal
deleted
inserted
replaced
9866:09cc8c856e5e | 9867:984f27e4b8a3 |
---|---|
167 api_instance.environment = pluginenv; | 167 api_instance.environment = pluginenv; |
168 | 168 |
169 local mod, err = pluginloader.load_code(module_name, nil, pluginenv); | 169 local mod, err = pluginloader.load_code(module_name, nil, pluginenv); |
170 if not mod then | 170 if not mod then |
171 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); | 171 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); |
172 api_instance:set_status("error", "Failed to load (see log)"); | |
172 return nil, err; | 173 return nil, err; |
173 end | 174 end |
174 | 175 |
175 api_instance.path = err; | 176 api_instance.path = err; |
176 | 177 |
180 -- Call module's "load" | 181 -- Call module's "load" |
181 if module_has_method(pluginenv, "load") then | 182 if module_has_method(pluginenv, "load") then |
182 ok, err = call_module_method(pluginenv, "load"); | 183 ok, err = call_module_method(pluginenv, "load"); |
183 if not ok then | 184 if not ok then |
184 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); | 185 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); |
186 api_instance:set_status("warn", "Error during load (see log)"); | |
185 end | 187 end |
186 end | 188 end |
187 api_instance.reloading, api_instance.saved_state = nil, nil; | 189 api_instance.reloading, api_instance.saved_state = nil, nil; |
188 | 190 |
189 if api_instance.host == "*" then | 191 if api_instance.host == "*" then |
202 end | 204 end |
203 end | 205 end |
204 if not ok then | 206 if not ok then |
205 modulemap[api_instance.host][module_name] = nil; | 207 modulemap[api_instance.host][module_name] = nil; |
206 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); | 208 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); |
209 api_instance:set_status("warn", "Error during load (see log)"); | |
210 else | |
211 api_instance:set_status("core", "Loaded", false); | |
207 end | 212 end |
208 return ok and pluginenv, err; | 213 return ok and pluginenv, err; |
209 end | 214 end |
210 | 215 |
211 local function do_reload_module(host, name) | 216 local function do_reload_module(host, name) |