How to add muc component without restarting the prosody server

470 views Asked by At

To add muc component without restarting the prosody server done the following code then trying to execute it using rest api. but muc component not able to loading .

--------------code begin---------------
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);

-----code end-----------------

How can we enable muc service point without reloading the prosody server.

1

There are 1 answers

0
MAK On BEST ANSWER

Using below code we can able achieve it

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

            --appending the text to config file
            local file_name="/etc/prosody/prosody.cfg.lua"
            file = io.open(file_name, "a")
            file:write(append_text)
            file:close()
            -- load & activate new muc server
            local lstatus=cmg.load(file_name)
            local new_server_status = hm.activate(muc_host)
            mm.load_modules_for_host(host)