如何添加睦组件,无需重新启动服务器韵律
问题描述:
无需重新启动服务器韵律做 下面的代码,然后尝试使用REST API来执行它添加睦组件。 但睦组件无法加载。如何添加睦组件,无需重新启动服务器韵律
--------------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-----------------
我们怎样才能使睦服务点无需重新加载韵律服务器。
答
使用下面的代码就可以实现能它
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)