Software / code / prosody
Comparison
prosodyctl @ 1487:66f18c18befa
Merge with main branch.
| author | Tobias Markmann <tm@ayena.de> |
|---|---|
| date | Sun, 05 Jul 2009 19:05:25 +0200 |
| parent | 1460:5882ed6219ff |
| child | 1499:51e3e22b5316 |
comparison
equal
deleted
inserted
replaced
| 1486:3e04efa8af7e | 1487:66f18c18befa |
|---|---|
| 93 ["no-password"] = "No password was supplied"; | 93 ["no-password"] = "No password was supplied"; |
| 94 ["no-such-user"] = "The given user does not exist on the server"; | 94 ["no-such-user"] = "The given user does not exist on the server"; |
| 95 ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?"; | 95 ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?"; |
| 96 ["no-pidfile"] = "There is no pidfile option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help"; | 96 ["no-pidfile"] = "There is no pidfile option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help"; |
| 97 ["no-such-method"] = "This module has no commands"; | 97 ["no-such-method"] = "This module has no commands"; |
| 98 ["not-running"] = "Prosody is not running"; | |
| 98 }, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end }); | 99 }, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end }); |
| 99 | 100 |
| 100 hosts = {}; | 101 hosts = {}; |
| 101 | 102 |
| 102 require "core.hostmanager" | 103 require "core.hostmanager" |
| 103 require "core.eventmanager".fire_event("server-starting"); | 104 require "core.eventmanager".fire_event("server-starting"); |
| 104 require "core.modulemanager" | 105 require "core.modulemanager" |
| 105 | 106 |
| 106 require "util.prosodyctl" | 107 require "util.prosodyctl" |
| 108 require "socket" | |
| 107 ----------------------- | 109 ----------------------- |
| 108 | 110 |
| 109 function show_message(msg, ...) | 111 function show_message(msg, ...) |
| 110 print(msg:format(...)); | 112 print(msg:format(...)); |
| 111 end | 113 end |
| 161 break; | 163 break; |
| 162 end | 164 end |
| 163 end | 165 end |
| 164 return password; | 166 return password; |
| 165 end | 167 end |
| 168 | |
| 169 local prosodyctl_timeout = (config.get("*", "core", "prosodyctl_timeout") or 5) * 2; | |
| 166 ----------------------- | 170 ----------------------- |
| 167 local commands = {}; | 171 local commands = {}; |
| 168 local command = arg[1]; | 172 local command = arg[1]; |
| 169 | 173 |
| 170 function commands.adduser(arg) | 174 function commands.adduser(arg) |
| 289 show_message("Prosody is already running with PID %s", ret or "(unknown)"); | 293 show_message("Prosody is already running with PID %s", ret or "(unknown)"); |
| 290 return 1; | 294 return 1; |
| 291 end | 295 end |
| 292 | 296 |
| 293 local ok, ret = prosodyctl.start(); | 297 local ok, ret = prosodyctl.start(); |
| 294 if ok then return 0; end | 298 if ok then |
| 299 local i=1; | |
| 300 while true do | |
| 301 local ok, running = prosodyctl.isrunning(); | |
| 302 if ok and running then | |
| 303 break; | |
| 304 elseif i == 5 then | |
| 305 show_message("Still waiting..."); | |
| 306 elseif i >= prosodyctl_timeout then | |
| 307 show_message("Prosody is still not running. Please give it some time or check your log files for errors."); | |
| 308 return 2; | |
| 309 end | |
| 310 socket.sleep(0.5); | |
| 311 i = i + 1; | |
| 312 end | |
| 313 show_message("Started"); | |
| 314 return 0; | |
| 315 end | |
| 295 | 316 |
| 296 show_message("Failed to start Prosody"); | 317 show_message("Failed to start Prosody"); |
| 297 show_message(error_messages[ret]) | 318 show_message(error_messages[ret]) |
| 298 return 1; | 319 return 1; |
| 299 end | 320 end |
| 342 show_message("Prosody is not running"); | 363 show_message("Prosody is not running"); |
| 343 return 1; | 364 return 1; |
| 344 end | 365 end |
| 345 | 366 |
| 346 local ok, ret = prosodyctl.stop(); | 367 local ok, ret = prosodyctl.stop(); |
| 347 if ok then return 0; end | 368 if ok then |
| 369 local i=1; | |
| 370 while true do | |
| 371 local ok, running = prosodyctl.isrunning(); | |
| 372 if ok and not running then | |
| 373 break; | |
| 374 elseif i == 5 then | |
| 375 show_message("Still waiting..."); | |
| 376 elseif i >= prosodyctl_timeout then | |
| 377 show_message("Prosody is still running. Please give it some time or check your log files for errors."); | |
| 378 return 2; | |
| 379 end | |
| 380 socket.sleep(0.5); | |
| 381 i = i + 1; | |
| 382 end | |
| 383 show_message("Stopped"); | |
| 384 return 0; | |
| 385 end | |
| 348 | 386 |
| 349 show_message(error_messages[ret]); | 387 show_message(error_messages[ret]); |
| 350 return 1; | 388 return 1; |
| 351 end | 389 end |
| 352 | 390 |