diff options
author | Vladimir Protasov <eoranged@ya.ru> | 2011-08-04 21:26:15 +0400 |
---|---|---|
committer | Vladimir Protasov <eoranged@ya.ru> | 2011-08-04 21:26:15 +0400 |
commit | d20a983470e1fa3d72942b879608f0d89b93bbd1 (patch) | |
tree | 710127305f28052eb782d092c9ceda8c29cf5123 | |
parent | 28b366799e638afa66eddb1fe103c528c4414569 (diff) | |
download | prosody-d20a983470e1fa3d72942b879608f0d89b93bbd1.tar.gz prosody-d20a983470e1fa3d72942b879608f0d89b93bbd1.zip |
Add "reload" command to prosodyctl
-rwxr-xr-x | prosodyctl | 23 | ||||
-rw-r--r-- | util/prosodyctl.lua | 16 |
2 files changed, 38 insertions, 1 deletions
@@ -538,6 +538,27 @@ function commands.about(arg) print(""); end +function commands.reload(arg) + if arg[1] == "--help" then + show_usage([[reload]], [[Reload prosody configuration file]]); + return 1; + end + + if not prosodyctl.isrunning() then + show_message("Prosody is not running"); + return 1; + end + + local ok, ret = prosodyctl.reload(); + if ok then + + show_message("Config updated"); + return 0; + end + + show_message(error_messages[ret]); + return 1; +end -- ejabberdctl compatibility function commands.register(arg) @@ -641,7 +662,7 @@ if not commands[command] then -- Show help for all commands print("Where COMMAND may be one of:\n"); local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; - local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "about" }; + local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", "about" }; local done = {}; diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua index aa1850b2..d0045abc 100644 --- a/util/prosodyctl.lua +++ b/util/prosodyctl.lua @@ -238,3 +238,19 @@ function stop() signal.kill(pid, signal.SIGTERM); return true; end + +function reload() + local ok, ret = _M.isrunning(); + if not ok then + return ok, ret; + end + if not ret then + return false, "not-running"; + end + + local ok, pid = _M.getpid() + if not ok then return false, pid; end + + signal.kill(pid, signal.SIGHUP); + return true; +end |