如何在不重新启动prosody服务器的情况下添加muc组件

要在不重新启动prosody服务器的情况下添加muc组件,请执行以下代码并尝试使用REST API进行执行。但是,muc组件无法加载。

--------------代码开始---------------
localh hm = require "core.hostmanager";
local mm = require "core.modulemanager";

host= "muc.example.co";
hm.activate(host);
local key= "component_module";
local value = "muc";
cmg._M.set(host, key, value);
mm.load_modules_for_host(host);

-----代码结束-----------------

我们如何在重新加载prosody服务器的情况下启用muc服务点。

点赞
用户1156798
用户1156798

使用以下代码我们可以实现它

local muc_host= "test.example.com"
local hm = require "core.hostmanager";
local cmg = require "core.configmanager";
local append_text= 'Component "'..muc_host..'" "muc" \n'

            --将文本附加到配置文件
            local file_name="/etc/prosody/prosody.cfg.lua"
            file = io.open(file_name, "a")
            file:write(append_text)
            file:close()
            -- 加载并激活新的 muc 服务器
            local lstatus=cmg.load(file_name)
            local new_server_status = hm.activate(muc_host)
            mm.load_modules_for_host(host)
2017-01-02 10:25:38