Software /
code /
prosody
Comparison
prosodyctl @ 10608:87003b937672 0.11
Log warning when using prosodyctl start/stop/restart
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 23 Jan 2020 21:43:36 +0000 |
parent | 10578:419ac5ef2d3d |
child | 10609:f35cbfe546d1 |
child | 10610:b9a054ad38e7 |
comparison
equal
deleted
inserted
replaced
10607:a845c877d997 | 10608:87003b937672 |
---|---|
196 | 196 |
197 show_message(error_messages[msg]) | 197 show_message(error_messages[msg]) |
198 return 1; | 198 return 1; |
199 end | 199 end |
200 | 200 |
201 local function service_command_warning(command) | |
202 if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then | |
203 show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended"); | |
204 show_warning(" if Prosody is managed by an init system - use that directly instead."); | |
205 if lfs.attributes("/etc/systemd") then | |
206 show_warning(" e.g. systemctl %s prosody", command); | |
207 elseif lfs.attributes("/etc/init.d/prosody") then | |
208 show_warning(" e.g. /etc/init.d/prosody %s", command); | |
209 end | |
210 show_warning(""); | |
211 end | |
212 end | |
213 | |
201 function commands.start(arg) | 214 function commands.start(arg) |
202 if arg[1] == "--help" then | 215 if arg[1] == "--help" then |
203 show_usage([[start]], [[Start Prosody]]); | 216 show_usage([[start]], [[Start Prosody]]); |
204 return 1; | 217 return 1; |
205 end | 218 end |
219 service_command_warning("start"); | |
206 local ok, ret = prosodyctl.isrunning(); | 220 local ok, ret = prosodyctl.isrunning(); |
207 if not ok then | 221 if not ok then |
208 show_message(error_messages[ret]); | 222 show_message(error_messages[ret]); |
209 return 1; | 223 return 1; |
210 end | 224 end |
290 function commands.stop(arg) | 304 function commands.stop(arg) |
291 if arg[1] == "--help" then | 305 if arg[1] == "--help" then |
292 show_usage([[stop]], [[Stop a running Prosody server]]); | 306 show_usage([[stop]], [[Stop a running Prosody server]]); |
293 return 1; | 307 return 1; |
294 end | 308 end |
309 | |
310 service_command_warning("stop"); | |
295 | 311 |
296 if not prosodyctl.isrunning() then | 312 if not prosodyctl.isrunning() then |
297 show_message("Prosody is not running"); | 313 show_message("Prosody is not running"); |
298 return 1; | 314 return 1; |
299 end | 315 end |
325 function commands.restart(arg) | 341 function commands.restart(arg) |
326 if arg[1] == "--help" then | 342 if arg[1] == "--help" then |
327 show_usage([[restart]], [[Restart a running Prosody server]]); | 343 show_usage([[restart]], [[Restart a running Prosody server]]); |
328 return 1; | 344 return 1; |
329 end | 345 end |
346 | |
347 service_command_warning("restart"); | |
330 | 348 |
331 commands.stop(arg); | 349 commands.stop(arg); |
332 return commands.start(arg); | 350 return commands.start(arg); |
333 end | 351 end |
334 | 352 |
418 function commands.reload(arg) | 436 function commands.reload(arg) |
419 if arg[1] == "--help" then | 437 if arg[1] == "--help" then |
420 show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]); | 438 show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]); |
421 return 1; | 439 return 1; |
422 end | 440 end |
441 | |
442 service_command_warning("reload"); | |
423 | 443 |
424 if not prosodyctl.isrunning() then | 444 if not prosodyctl.isrunning() then |
425 show_message("Prosody is not running"); | 445 show_message("Prosody is not running"); |
426 return 1; | 446 return 1; |
427 end | 447 end |