Software / code / prosody
Comparison
core/hostmanager.lua @ 3597:8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 10 Nov 2010 19:57:35 +0500 |
| parent | 3594:d3b57562cd87 |
| child | 3599:adc0b4df6fdd |
comparison
equal
deleted
inserted
replaced
| 3596:bbeba9f2acf8 | 3597:8090880f0e18 |
|---|---|
| 30 local function load_enabled_hosts(config) | 30 local function load_enabled_hosts(config) |
| 31 local defined_hosts = config or configmanager.getconfig(); | 31 local defined_hosts = config or configmanager.getconfig(); |
| 32 local activated_any_host; | 32 local activated_any_host; |
| 33 | 33 |
| 34 for host, host_config in pairs(defined_hosts) do | 34 for host, host_config in pairs(defined_hosts) do |
| 35 if host ~= "*" and host_config.core.enabled ~= false and not host_config.core.component_module then | 35 if host ~= "*" and host_config.core.enabled ~= false then |
| 36 activated_any_host = true; | 36 if not host_config.core.component_module then |
| 37 activated_any_host = true; | |
| 38 end | |
| 37 activate(host, host_config); | 39 activate(host, host_config); |
| 38 end | 40 end |
| 39 end | 41 end |
| 40 | 42 |
| 41 if not activated_any_host then | 43 if not activated_any_host then |
| 47 end | 49 end |
| 48 | 50 |
| 49 prosody_events.add_handler("server-starting", load_enabled_hosts); | 51 prosody_events.add_handler("server-starting", load_enabled_hosts); |
| 50 | 52 |
| 51 function activate(host, host_config) | 53 function activate(host, host_config) |
| 54 if hosts[host] then return nil, "host-already-exists"; end | |
| 52 local host_session = { | 55 local host_session = { |
| 53 host = host; | 56 host = host; |
| 54 s2sout = {}; | 57 s2sout = {}; |
| 55 events = events_new(); | 58 events = events_new(); |
| 56 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); | 59 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); |
| 72 end | 75 end |
| 73 end | 76 end |
| 74 | 77 |
| 75 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); | 78 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); |
| 76 prosody_events.fire_event("host-activated", host, host_config); | 79 prosody_events.fire_event("host-activated", host, host_config); |
| 80 return true; | |
| 77 end | 81 end |
| 78 | 82 |
| 79 function deactivate(host, reason) | 83 function deactivate(host, reason) |
| 80 local host_session = hosts[host]; | 84 local host_session = hosts[host]; |
| 81 log("info", "Deactivating host: %s", host); | 85 log("info", "Deactivating host: %s", host); |