Software /
code /
prosody
Comparison
plugins/mod_console.lua @ 1496:4fa337035f46
mod_console: server:version() and server:uptime() commands
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 08 Jul 2009 04:32:02 +0100 |
parent | 1491:694a0a00e1a5 |
child | 1502:0f895c06e03f |
comparison
equal
deleted
inserted
replaced
1495:6c745a108e68 | 1496:4fa337035f46 |
---|---|
157 function def_env.server:reload() | 157 function def_env.server:reload() |
158 prosody.unlock_globals(); | 158 prosody.unlock_globals(); |
159 dofile "prosody" | 159 dofile "prosody" |
160 prosody = _G.prosody; | 160 prosody = _G.prosody; |
161 return true, "Server reloaded"; | 161 return true, "Server reloaded"; |
162 end | |
163 | |
164 function def_env.server:version() | |
165 return true, tostring(prosody.version or "unknown"); | |
166 end | |
167 | |
168 function def_env.server:uptime() | |
169 local t = os.time()-prosody.start_time; | |
170 local seconds = t%60; | |
171 t = (t - seconds)/60; | |
172 local minutes = t%60; | |
173 t = (t - minutes)/60; | |
174 local hours = t%24; | |
175 t = (t - hours)/24; | |
176 local days = t; | |
177 return true, string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", | |
178 days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", | |
179 minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time)); | |
162 end | 180 end |
163 | 181 |
164 def_env.module = {}; | 182 def_env.module = {}; |
165 | 183 |
166 local function get_hosts_set(hosts, module) | 184 local function get_hosts_set(hosts, module) |