forked from denysboiko/coincosm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
46 lines (35 loc) · 1.29 KB
/
start.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
var argv = require('optimist').argv;
var servers = require('./lib/coinpunk/server');
var config = require('./lib/coinpunk/server/config');
// Pick the config environment we're running in if
// one is specified. Otherwise, just use 'default'.
// And if there is no 'default' key, assume we're
// looking at an 'old-style' config.json and use it
// as-is.
var env = argv.env || "default";
if(env in config)
config = config[env];
if(argv.httpPort)
config.httpPort = argv.httpPort;
if(argv.httpsPort)
config.httpsPort = argv.httpsPort;
// Kick off the server!
(new servers.Server(config)).start();
console.log("Coincosm run successfully");
var domain = require('domain').create();
domain.on('error', function(err) {
console.error(err.stack);
});
domain.run(function() {
if(servers.httpsServer)
servers.httpsServer.listen(config.httpsPort || 443);
if(servers.httpServer)
servers.httpServer.listen(config.httpPort || argv.p || 80);
});
/*servers.express.engine('.html', require('ejs').__express);
servers.express.set('views',__dirname+'/public/templates');
servers.express.set('view engine', 'html');
servers.express.set('view options', { layout: true, root: __dirname + '/public/templates' } );
servers.express.get('/page1', function(req, res){
res.render('main', { name: "Sasai Lalka"});
});*/