Comparison

util/prosodyctl.lua @ 10132:b59535964e81

util.prosodyctl: Moved the 'admin_operation' function from prosodyctl to here
author João Duarte <jvsDuarte08@gmail.com>
date Tue, 25 Jun 2019 13:20:54 +0100
parent 9781:161411a41377
child 10136:38775965fcd5
comparison
equal deleted inserted replaced
10131:0780bcf51ba7 10132:b59535964e81
274 local ok, pid = getpid() 274 local ok, pid = getpid()
275 if not ok then return false, pid; end 275 if not ok then return false, pid; end
276 276
277 signal.kill(pid, signal.SIGHUP); 277 signal.kill(pid, signal.SIGHUP);
278 return true; 278 return true;
279 end
280
281 local function admin_operation(operation, arg)
282 local modules, tree, server, refresh = "", "", "", ""
283 for i, _ in ipairs(arg) do
284 if arg[i]:sub(1, #"--tree=") == "--tree=" then
285 tree = arg[i].." "
286 elseif arg[i]:sub(1, #"--server=") == "--server=" then
287 server = arg[i].." "
288 elseif arg[i]:sub(1, #"--no-refresh") == "--no-refresh" then
289 refresh = arg[i].." "
290 else
291 modules=modules..arg[i].." "
292 end
293 end
294 os.execute("luarocks-admin "..tree..operation..server..refresh..modules)
279 end 295 end
280 296
281 return { 297 return {
282 show_message = show_message; 298 show_message = show_message;
283 show_warning = show_message; 299 show_warning = show_message;
295 getpid = getpid; 311 getpid = getpid;
296 isrunning = isrunning; 312 isrunning = isrunning;
297 start = start; 313 start = start;
298 stop = stop; 314 stop = stop;
299 reload = reload; 315 reload = reload;
316 admin_operation = admin_operation;
300 }; 317 };