wl.on('destroy', function (client) {
clients.remove(client);
});
+
+ wl.on('listening', webListenerRunning);
});
+// Once all the listeners are listening, set the processes UID/GID
+var num_listening = 0;
+function webListenerRunning() {
+ num_listening++;
+ if (num_listening === global.config.servers.length) {
+ setProcessUid();
+ }
+}
process.title = 'kiwiirc';
// Change UID/GID
-if ((global.config.group) && (global.config.group !== '')) {
- process.setgid(global.config.group);
-}
-if ((global.config.user) && (global.config.user !== '')) {
- process.setuid(global.config.user);
+function setProcessUid() {
+ if ((global.config.group) && (global.config.group !== '')) {
+ process.setgid(global.config.group);
+ }
+ if ((global.config.user) && (global.config.user !== '')) {
+ process.setuid(global.config.user);
+ }
}
// Start socket.io listening on this weblistener
this.ws = ws.listen(hs, _.extend({ssl: true}, ws_opts));
- hs.listen(web_config.port, web_config.address);
+ hs.listen(web_config.port, web_config.address, function () {
+ that.emit('listening');
+ });
console.log('Listening on ' + web_config.address + ':' + web_config.port.toString() + ' with SSL');
} else {
// Start socket.io listening on this weblistener
this.ws = ws.listen(hs, _.extend({ssl: false}, ws_opts));
- hs.listen(web_config.port, web_config.address);
+ hs.listen(web_config.port, web_config.address, function () {
+ that.emit('listening');
+ });
console.log('Listening on ' + web_config.address + ':' + web_config.port.toString() + ' without SSL');
}