mod_auto_activate_hosts/mod_auto_activate_hosts.lua
changeset 1343 7dbde05b48a9
parent 1013 8285c3502100
child 1822 8b7bca07f5c0
equal deleted inserted replaced
1342:0ae065453dc9 1343:7dbde05b48a9
    17 	local new_config = config.getconfig();
    17 	local new_config = config.getconfig();
    18 	local active_hosts = set.new(array.collect(it.keys(prosody.hosts)):filter(host_not_global));
    18 	local active_hosts = set.new(array.collect(it.keys(prosody.hosts)):filter(host_not_global));
    19 	local enabled_hosts = set.new(array.collect(it.keys(new_config)):filter(host_is_enabled):filter(host_not_global));
    19 	local enabled_hosts = set.new(array.collect(it.keys(new_config)):filter(host_is_enabled):filter(host_not_global));
    20 	local need_to_activate = enabled_hosts - active_hosts;
    20 	local need_to_activate = enabled_hosts - active_hosts;
    21 	local need_to_deactivate = active_hosts - enabled_hosts;
    21 	local need_to_deactivate = active_hosts - enabled_hosts;
    22 	
    22 
    23 	module:log("debug", "Config reloaded... %d hosts need activating, and %d hosts need deactivating", it.count(need_to_activate), it.count(need_to_deactivate));
    23 	module:log("debug", "Config reloaded... %d hosts need activating, and %d hosts need deactivating", it.count(need_to_activate), it.count(need_to_deactivate));
    24 	module:log("debug", "There are %d enabled and %d active hosts", it.count(enabled_hosts), it.count(active_hosts));	
    24 	module:log("debug", "There are %d enabled and %d active hosts", it.count(enabled_hosts), it.count(active_hosts));
    25 	for host in need_to_deactivate do
    25 	for host in need_to_deactivate do
    26 		hostmanager.deactivate(host);
    26 		hostmanager.deactivate(host);
    27 	end
    27 	end
    28 	
    28 
    29 	-- If the lazy loader is loaded, hosts will get activated when they are needed
    29 	-- If the lazy loader is loaded, hosts will get activated when they are needed
    30 	if not(getmetatable(prosody.hosts) and getmetatable(prosody.hosts).lazy_loader) then
    30 	if not(getmetatable(prosody.hosts) and getmetatable(prosody.hosts).lazy_loader) then
    31 		for host in need_to_activate do
    31 		for host in need_to_activate do
    32 			hostmanager.activate(host);
    32 			hostmanager.activate(host);
    33 		end
    33 		end