prosodyctl
changeset 10613 f35cbfe546d1
parent 10583 16099e8964d8
parent 10612 87003b937672
child 10615 c10511380c0f
equal deleted inserted replaced
10608:3b0d9919f361 10613:f35cbfe546d1
   220 
   220 
   221 	show_message(error_messages[msg])
   221 	show_message(error_messages[msg])
   222 	return 1;
   222 	return 1;
   223 end
   223 end
   224 
   224 
       
   225 local function service_command_warning(command)
       
   226 	if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then
       
   227 		show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended");
       
   228 		show_warning("         if Prosody is managed by an init system - use that directly instead.");
       
   229 		if lfs.attributes("/etc/systemd") then
       
   230 			show_warning("         e.g. systemctl %s prosody", command);
       
   231 		elseif lfs.attributes("/etc/init.d/prosody") then
       
   232 			show_warning("         e.g. /etc/init.d/prosody %s", command);
       
   233 		end
       
   234 		show_warning("");
       
   235 	end
       
   236 end
       
   237 
   225 function commands.start(arg)
   238 function commands.start(arg)
   226 	if arg[1] == "--help" then
   239 	if arg[1] == "--help" then
   227 		show_usage([[start]], [[Start Prosody]]);
   240 		show_usage([[start]], [[Start Prosody]]);
   228 		return 1;
   241 		return 1;
   229 	end
   242 	end
       
   243 	service_command_warning("start");
   230 	local ok, ret = prosodyctl.isrunning();
   244 	local ok, ret = prosodyctl.isrunning();
   231 	if not ok then
   245 	if not ok then
   232 		show_message(error_messages[ret]);
   246 		show_message(error_messages[ret]);
   233 		return 1;
   247 		return 1;
   234 	end
   248 	end
   322 function commands.stop(arg)
   336 function commands.stop(arg)
   323 	if arg[1] == "--help" then
   337 	if arg[1] == "--help" then
   324 		show_usage([[stop]], [[Stop a running Prosody server]]);
   338 		show_usage([[stop]], [[Stop a running Prosody server]]);
   325 		return 1;
   339 		return 1;
   326 	end
   340 	end
       
   341 
       
   342 	service_command_warning("stop");
   327 
   343 
   328 	if not prosodyctl.isrunning() then
   344 	if not prosodyctl.isrunning() then
   329 		show_message("Prosody is not running");
   345 		show_message("Prosody is not running");
   330 		return 1;
   346 		return 1;
   331 	end
   347 	end
   357 function commands.restart(arg)
   373 function commands.restart(arg)
   358 	if arg[1] == "--help" then
   374 	if arg[1] == "--help" then
   359 		show_usage([[restart]], [[Restart a running Prosody server]]);
   375 		show_usage([[restart]], [[Restart a running Prosody server]]);
   360 		return 1;
   376 		return 1;
   361 	end
   377 	end
       
   378 
       
   379 	service_command_warning("restart");
   362 
   380 
   363 	commands.stop(arg);
   381 	commands.stop(arg);
   364 	return commands.start(arg);
   382 	return commands.start(arg);
   365 end
   383 end
   366 
   384 
   457 function commands.reload(arg)
   475 function commands.reload(arg)
   458 	if arg[1] == "--help" then
   476 	if arg[1] == "--help" then
   459 		show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]);
   477 		show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]);
   460 		return 1;
   478 		return 1;
   461 	end
   479 	end
       
   480 
       
   481 	service_command_warning("reload");
   462 
   482 
   463 	if not prosodyctl.isrunning() then
   483 	if not prosodyctl.isrunning() then
   464 		show_message("Prosody is not running");
   484 		show_message("Prosody is not running");
   465 		return 1;
   485 		return 1;
   466 	end
   486 	end