// If we're not running in the forground and we have a log file.. switch
// console.log to output to a file
-if (process.argv.indexOf('-f') === -1 && global.config.log) {
+if (process.argv.indexOf('-f') === -1 && global.config && global.config.log) {
(function () {
var log_file_name = global.config.log;
}
};
+global.servers = {
+ servers: Object.create(null),
+
+ addConnection: function (connection) {
+ var host = connection.irc_host.hostname;
+ if (!this.servers[host]) {
+ this.servers[host] = [];
+ }
+ this.servers[host].push(connection);
+ },
+
+ removeConnection: function (connection) {
+ var host = connection.irc_host.hostname
+ if (this.servers[host]) {
+ this.servers[host] = _.without(this.servers[host], connection);
+ if (this.servers[host].length === 0) {
+ delete this.servers[host];
+ }
+ }
+ },
+
+ numOnHost: function (host) {
+ if (this.servers[host]) {
+ return this.servers[host].length;
+ } else {
+ return 0;
+ }
+ }
+};
+
clients.remove(client);
});
- wl.on('listening', webListenerRunning);
+ wl.on('listening', function () {
+ console.log('Listening on %s:%s %s SSL', server.address, server.port, (server.ssl ? 'with' : 'without'));
+ webListenerRunning();
+ });
+
+ wl.on('error', function (err) {
+ console.log('Error listening on %s:%s: %s', server.address, server.port, err.code);
+ // TODO: This should probably be refactored. ^JA
+ webListenerRunning();
+ });
});
// Once all the listeners are listening, set the processes UID/GID