Comparison

util/prosodyctl.lua @ 8668:31c5abd49dfe

prosodyctl, util.prosodyctl: Pass source path as a parameter instead of global variable
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Mar 2018 21:54:59 +0000
parent 8634:f6f62c92b642
child 8883:3f975bbfec3b
comparison
equal deleted inserted replaced
8667:a05d36075c6a 8668:31c5abd49dfe
22 22
23 local io, os = io, os; 23 local io, os = io, os;
24 local print = print; 24 local print = print;
25 local tonumber = tonumber; 25 local tonumber = tonumber;
26 26
27 local CFG_SOURCEDIR = _G.CFG_SOURCEDIR;
28
29 local _G = _G; 27 local _G = _G;
30 local prosody = prosody; 28 local prosody = prosody;
31 29
32 -- UI helpers 30 -- UI helpers
33 local function show_message(msg, ...) 31 local function show_message(msg, ...)
229 return ok, pid; 227 return ok, pid;
230 end 228 end
231 return true, signal.kill(pid, 0) == 0; 229 return true, signal.kill(pid, 0) == 0;
232 end 230 end
233 231
234 local function start() 232 local function start(source_dir)
235 local ok, ret = isrunning(); 233 local ok, ret = isrunning();
236 if not ok then 234 if not ok then
237 return ok, ret; 235 return ok, ret;
238 end 236 end
239 if ret then 237 if ret then
240 return false, "already-running"; 238 return false, "already-running";
241 end 239 end
242 if not CFG_SOURCEDIR then 240 if not source_dir then
243 os.execute("./prosody"); 241 os.execute("./prosody");
244 else 242 else
245 os.execute(CFG_SOURCEDIR.."/../../bin/prosody"); 243 os.execute(source_dir.."/../../bin/prosody");
246 end 244 end
247 return true; 245 return true;
248 end 246 end
249 247
250 local function stop() 248 local function stop()