forked from netbeast/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·40 lines (32 loc) · 1015 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
// Node native libraries
var path = require('path')
var http = require('http')
// NPM dependencies
var forever = require('forever-monitor')
var io = require('socket.io')()
var cmd = require('commander')
require('app-module-path')
.addPath(__dirname)
// Project libraries
var app = require('src')
var config = require('config')
var bootOnload = require('src/boot-on-load')
cmd
.version('0.1.42')
.option('-p, --port <n>', 'Port to start the HTTP server', parseInt)
.parse(process.argv)
// Launch server with web sockets
var server = module.exports = http.createServer(app)
server.listen(cmd.port || config.port, function () {
console.log('Netbeast dashboard started on %s:%s',
server.address().address,
server.address().port)
bootOnload()
})
io.listen(server)
io.on('connection', require('src/broker'))
// Start the deamon that recognises other netbeasts
var deamonBin = path.join(__dirname, 'bin/deamon.js')
var deamon = new (forever.Monitor)(deamonBin, {max: 1})
deamon.start()