Merge branch 'master' of github.com:wiedi/node-dmx

This commit is contained in:
Sebastian Wiedenroth 2013-06-12 23:24:49 +02:00
commit 9864ef4d72
3 changed files with 20 additions and 2 deletions

8
config.js Normal file
View file

@ -0,0 +1,8 @@
// webserver configuration
// listen port
exports.port = 80;
// uid and gid to drop root priv.
exports.uid = 'light';
exports.gid = 'users';

4
dmx.js
View file

@ -1,4 +1,5 @@
var events = require('events')
, config = require('./config.js')
, web = require('./web.js')
, setup = require('./setup.js').setup
, devices = require('./devices.js').devices
@ -7,6 +8,7 @@ var events = require('events')
var dmx = new events.EventEmitter();
dmx.config = config;
dmx.setup = setup;
dmx.devices = devices;
dmx.drivers = {};
@ -22,4 +24,4 @@ for(var universe in setup.universes) {
}
web.init(dmx);
web.init(dmx);

10
web.js
View file

@ -49,7 +49,15 @@ exports.init = function(dmx) {
var app = http.createServer(handler)
app.listen(8080, '::');
app.listen(dmx.config.port, '::', null, function() {
try {
process.setgid(dmx.config.gid);
process.setuid(dmx.config.uid);
} catch (err) {
console.log(err);
process.exit(1);
}
});
io.listen(app).sockets.on('connection', function (socket) {
socket.emit('init', {'devices': dmx.devices, 'setup': dmx.setup});