-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (57 loc) · 1.88 KB
/
app.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
var express = require('express')
, sharejs = require('share').server
, exec = require('child_process').exec
, ProjectProvider = require(__dirname + '/models/projectprovider-mongodb').ProjectProvider
, chatServer = require('./lib/now-service.js');
var app = express();
app.disable('quiet');
express.limit('10mb');
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('prject', __dirname + '/views/project');
app.set('prject', __dirname + '/views/account');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: 'osu-hci-collabcoding' }));
app.use(express.methodOverride());
app.use(require('stylus').middleware({
src: __dirname + '/public',
compress: true
}));
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
require('./routes/index')(app)
var options = {db: {type: 'none'}}; // See docs for options. {type: 'redis'} to enable persistance.
// try {
// require('redis');
// options.db = {type: 'redis'};
// exec('redis-server &', function(err, stdout, stderr) {
// console.log('stdout:' + stdout);
// console.log('stderr:' + stderr);
// if (error) {
// console.log('exec error:' + error);
// }
// });
// } catch (e) {
//
// }
options.db = {type: 'mongo'};
options.auth = function(agent, action) {
action.accept();
};
// Attach the sharejs REST and Socket.io interfaces to the server
sharejs.attach(app, options);
var server;
exec('mongod &', function(err, stdout, stderr) {
server = app.listen(8001);
console.log('Server running at http://127.0.0.1:8001/');
chatServer.start(server);
});