Software /
code /
prosody
Comparison
prosodyctl @ 12971:7214baed9e9d
executables: Prefix module imports with prosody namespace
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 17 Mar 2023 16:29:54 +0100 |
parent | 12954:4f2accd99373 |
child | 13059:a47bd6ea7626 |
comparison
equal
deleted
inserted
replaced
12970:d36243e98704 | 12971:7214baed9e9d |
---|---|
53 | 53 |
54 if not pcall(require, "prosody.loader") then | 54 if not pcall(require, "prosody.loader") then |
55 pcall(require, "loader"); | 55 pcall(require, "loader"); |
56 end | 56 end |
57 | 57 |
58 local startup = require "util.startup"; | 58 local startup = require "prosody.util.startup"; |
59 startup.prosodyctl(); | 59 startup.prosodyctl(); |
60 | 60 |
61 ----------- | 61 ----------- |
62 | 62 |
63 local configmanager = require "core.configmanager"; | 63 local configmanager = require "prosody.core.configmanager"; |
64 local modulemanager = require "core.modulemanager" | 64 local modulemanager = require "prosody.core.modulemanager" |
65 local prosodyctl = require "util.prosodyctl" | 65 local prosodyctl = require "prosody.util.prosodyctl" |
66 local socket = require "socket" | 66 local socket = require "socket" |
67 local dependencies = require "util.dependencies"; | 67 local dependencies = require "prosody.util.dependencies"; |
68 local lfs = dependencies.softreq "lfs"; | 68 local lfs = dependencies.softreq "lfs"; |
69 | 69 |
70 ----------------------- | 70 ----------------------- |
71 | 71 |
72 local parse_args = require "util.argparse".parse; | 72 local parse_args = require "prosody.util.argparse".parse; |
73 local human_io = require "util.human.io"; | 73 local human_io = require "prosody.util.human.io"; |
74 | 74 |
75 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; | 75 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; |
76 local show_usage = prosodyctl.show_usage; | 76 local show_usage = prosodyctl.show_usage; |
77 local read_password = human_io.read_password; | 77 local read_password = human_io.read_password; |
78 local call_luarocks = prosodyctl.call_luarocks; | 78 local call_luarocks = prosodyctl.call_luarocks; |
79 local error_messages = prosodyctl.error_messages; | 79 local error_messages = prosodyctl.error_messages; |
80 | 80 |
81 local jid_split = require "util.jid".prepped_split; | 81 local jid_split = require "prosody.util.jid".prepped_split; |
82 | 82 |
83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; | 83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
84 ----------------------- | 84 ----------------------- |
85 local commands = {}; | 85 local commands = {}; |
86 local command = table.remove(arg, 1); | 86 local command = table.remove(arg, 1); |
436 show_usage([[about]], [[Show information about this Prosody installation]]); | 436 show_usage([[about]], [[Show information about this Prosody installation]]); |
437 return 0; | 437 return 0; |
438 end | 438 end |
439 | 439 |
440 local pwd = "."; | 440 local pwd = "."; |
441 local sorted_pairs = require "util.iterators".sorted_pairs; | 441 local sorted_pairs = require "prosody.util.iterators".sorted_pairs; |
442 local hg = require"util.mercurial"; | 442 local hg = require"prosody.util.mercurial"; |
443 local relpath = configmanager.resolve_relative_path; | 443 local relpath = configmanager.resolve_relative_path; |
444 | 444 |
445 print("Prosody "..(prosody.version or "(unknown version)")); | 445 print("Prosody "..(prosody.version or "(unknown version)")); |
446 print(""); | 446 print(""); |
447 print("# Prosody directories"); | 447 print("# Prosody directories"); |
459 hgrepo = hgrepo == "010452cfaf53" and "prosody-modules"; | 459 hgrepo = hgrepo == "010452cfaf53" and "prosody-modules"; |
460 return path..(hgid and " - "..(hgrepo or "HG").." rev: "..hgid or "") | 460 return path..(hgid and " - "..(hgrepo or "HG").." rev: "..hgid or "") |
461 .."\n "; | 461 .."\n "; |
462 end))); | 462 end))); |
463 print(""); | 463 print(""); |
464 local have_pposix, pposix = pcall(require, "util.pposix"); | 464 local have_pposix, pposix = pcall(require, "prosody.util.pposix"); |
465 if have_pposix and pposix.uname then | 465 if have_pposix and pposix.uname then |
466 print("# Operating system"); | 466 print("# Operating system"); |
467 local uname, err = pposix.uname(); | 467 local uname, err = pposix.uname(); |
468 print(uname and uname.sysname .. " " .. uname.release or "Unknown POSIX", err or ""); | 468 print(uname and uname.sysname .. " " .. uname.release or "Unknown POSIX", err or ""); |
469 print(""); | 469 print(""); |
492 end | 492 end |
493 print("LuaRocks: ", luarocks_status); | 493 print("LuaRocks: ", luarocks_status); |
494 print(""); | 494 print(""); |
495 print("# Network"); | 495 print("# Network"); |
496 print(""); | 496 print(""); |
497 print("Backend: "..require "net.server".get_backend()); | 497 print("Backend: "..require "prosody.net.server".get_backend()); |
498 print(""); | 498 print(""); |
499 print("# Lua module versions"); | 499 print("# Lua module versions"); |
500 local module_versions, longest_name = {}, 8; | 500 local module_versions, longest_name = {}, 8; |
501 local library_versions = {}; | 501 local library_versions = {}; |
502 dependencies.softreq"ssl"; | 502 dependencies.softreq"ssl"; |
514 -- These diverge from the module._VERSION convention | 514 -- These diverge from the module._VERSION convention |
515 readline = "Version"; | 515 readline = "Version"; |
516 } | 516 } |
517 local lunbound = dependencies.softreq"lunbound"; | 517 local lunbound = dependencies.softreq"lunbound"; |
518 local lxp = dependencies.softreq"lxp"; | 518 local lxp = dependencies.softreq"lxp"; |
519 local hashes = dependencies.softreq"util.hashes"; | 519 local hashes = dependencies.softreq"prosody.util.hashes"; |
520 for name, module in pairs(package.loaded) do | 520 for name, module in pairs(package.loaded) do |
521 local version_field = alternate_version_fields[name] or "_VERSION"; | 521 local version_field = alternate_version_fields[name] or "_VERSION"; |
522 if type(module) == "table" and rawget(module, version_field) | 522 if type(module) == "table" and rawget(module, version_field) |
523 and name ~= "_G" and not name:match("%.") then | 523 and name ~= "_G" and not name:match("%.") then |
524 name = friendly_names[name] or name; | 524 name = friendly_names[name] or name; |
547 for name, version in sorted_pairs(module_versions) do | 547 for name, version in sorted_pairs(module_versions) do |
548 print(name..":"..string.rep(" ", longest_name-#name), version); | 548 print(name..":"..string.rep(" ", longest_name-#name), version); |
549 end | 549 end |
550 print(""); | 550 print(""); |
551 print("# library versions"); | 551 print("# library versions"); |
552 if require "net.server".event_base then | 552 if require "prosody.net.server".event_base then |
553 library_versions["libevent"] = require"luaevent".core.libevent_version(); | 553 library_versions["libevent"] = require"luaevent".core.libevent_version(); |
554 end | 554 end |
555 for name, version in sorted_pairs(library_versions) do | 555 for name, version in sorted_pairs(library_versions) do |
556 print(name..":"..string.rep(" ", longest_name-#name), version); | 556 print(name..":"..string.rep(" ", longest_name-#name), version); |
557 end | 557 end |
637 return 1; | 637 return 1; |
638 end | 638 end |
639 | 639 |
640 --------------------- | 640 --------------------- |
641 | 641 |
642 local async = require "util.async"; | 642 local async = require "prosody.util.async"; |
643 local server = require "net.server"; | 643 local server = require "prosody.net.server"; |
644 local watchers = { | 644 local watchers = { |
645 error = function (_, err) | 645 error = function (_, err) |
646 error(err); | 646 error(err); |
647 end; | 647 end; |
648 waiting = function () | 648 waiting = function () |
684 os.exit(1); -- :( | 684 os.exit(1); -- :( |
685 end | 685 end |
686 end | 686 end |
687 | 687 |
688 if command and not commands[command] then | 688 if command and not commands[command] then |
689 local ok, command_module = pcall(require, "util.prosodyctl."..command); | 689 local ok, command_module = pcall(require, "prosody.util.prosodyctl."..command); |
690 if ok and command_module[command] then | 690 if ok and command_module[command] then |
691 commands[command] = command_module[command]; | 691 commands[command] = command_module[command]; |
692 end | 692 end |
693 end | 693 end |
694 | 694 |
701 print(""); | 701 print(""); |
702 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); | 702 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
703 print(""); | 703 print(""); |
704 print("Where COMMAND may be one of:"); | 704 print("Where COMMAND may be one of:"); |
705 | 705 |
706 local hidden_commands = require "util.set".new{ "register", "unregister" }; | 706 local hidden_commands = require "prosody.util.set".new{ "register", "unregister" }; |
707 local commands_order = { | 707 local commands_order = { |
708 "Process management:", | 708 "Process management:", |
709 "start"; "stop"; "restart"; "reload"; "status"; | 709 "start"; "stop"; "restart"; "reload"; "status"; |
710 "shell", | 710 "shell", |
711 "User management:", | 711 "User management:", |