mod_statistics/stats: Guard usage of module:get_option() so we only call it when Prosody is running

Sun, 18 Sep 2016 18:53:09 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 18 Sep 2016 18:53:09 +0100
changeset 2300
dded110af017
parent 2299
e099586f9de5
child 2301
d7c014f91189

mod_statistics/stats: Guard usage of module:get_option() so we only call it when Prosody is running

mod_statistics/stats.lib.lua file | annotate | diff | comparison | revisions
--- a/mod_statistics/stats.lib.lua	Sat Sep 17 18:04:46 2016 +0200
+++ b/mod_statistics/stats.lib.lua	Sun Sep 18 18:53:09 2016 +0100
@@ -32,8 +32,6 @@
 	c2s_sessions, s2s_sessions = module:shared("/*/c2s/sessions", "/*/s2s/sessions");
 end
 
-local memory_update_interval = module:get_option_number("statistics_meminfo_interval", 60);
-
 local stats = {
 	total_users = {
 		get = function () return it.count(it.keys(bare_sessions)); end
@@ -91,6 +89,12 @@
 	};
 };
 
+local memory_update_interval = 60;
+if prosody and prosody.arg then
+	memory_update_interval = module:get_option_number("statistics_meminfo_interval", 60);
+end
+
+
 if has_pposix and pposix.meminfo then
 
 	local cached_meminfo, last_cache_update;

mercurial