-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.coffee
29 lines (23 loc) · 949 Bytes
/
server.coffee
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
BrunchServer = require './lib/server'
{config} = require './config'
mongoose = require('mongoose')
module.exports.startServer = (port, path, callback) ->
# Configure the database connection
# TODO: Comment this back in once mongoose support is back.
#db = mongoose.connect('mongodb://localhost/test').connection
#db.on('error', console.error.bind(console, 'connection error:'))
#db.once('open', ->
# console.log("successfully opened mongodb connection with mongoose.")
#)
# Configure and start the server.
port = process.env.PORT || port
bsvr = new BrunchServer(config)
io = require('socket.io').listen bsvr.server, logger: bsvr.logger
io.set 'log level', 2
sockets = require('./express/sockets')(io)
bsvr.on 'reload', ->
sockets.emit '/brunch/reload', 1000
sockets.destroy()
sockets = require('./express/sockets')(io)
bsvr.start(port, callback)
bsvr