Comparison

core/portmanager.lua @ 5549:cce17bcb7c94

portmanager: Include port numbers the service is listening on in the info logs.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 29 Apr 2013 22:03:17 +0500
parent 5432:53b16286509a
child 5550:557583904dc5
comparison
equal deleted inserted replaced
5548:c5d1c35c93f4 5549:cce17bcb7c94
110 or listener.default_port -- COMPAT w/pre-0.9 110 or listener.default_port -- COMPAT w/pre-0.9
111 } 111 }
112 bind_ports = set.new(type(bind_ports) ~= "table" and { bind_ports } or bind_ports ); 112 bind_ports = set.new(type(bind_ports) ~= "table" and { bind_ports } or bind_ports );
113 113
114 local mode, ssl = listener.default_mode or "*a"; 114 local mode, ssl = listener.default_mode or "*a";
115 local hooked_ports = {};
115 116
116 for interface in bind_interfaces do 117 for interface in bind_interfaces do
117 for port in bind_ports do 118 for port in bind_ports do
118 local port_number = tonumber(port); 119 local port_number = tonumber(port);
119 if not port_number then 120 if not port_number then
150 -- Start listening on interface+port 151 -- Start listening on interface+port
151 local handler, err = server.addserver(interface, port_number, listener, mode, ssl); 152 local handler, err = server.addserver(interface, port_number, listener, mode, ssl);
152 if not handler then 153 if not handler then
153 log("error", "Failed to open server port %d on %s, %s", port_number, interface, error_to_friendly_message(service_name, port_number, err)); 154 log("error", "Failed to open server port %d on %s, %s", port_number, interface, error_to_friendly_message(service_name, port_number, err));
154 else 155 else
156 table.insert(hooked_ports, port_number);
155 log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port_number); 157 log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port_number);
156 active_services:add(service_name, interface, port_number, { 158 active_services:add(service_name, interface, port_number, {
157 server = handler; 159 server = handler;
158 service = service_info; 160 service = service_info;
159 }); 161 });
160 end 162 end
161 end 163 end
162 end 164 end
163 end 165 end
164 end 166 end
165 log("info", "Activated service '%s'", service_name); 167 log("info", "Activated service '%s' on %s", service_name, #hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", "));
166 return true; 168 return true;
167 end 169 end
168 170
169 function deactivate(service_name, service_info) 171 function deactivate(service_name, service_info)
170 for name, interface, port, n, active_service 172 for name, interface, port, n, active_service