Stackedit/index.js

30 lines
898 B
JavaScript
Raw Normal View History

2017-09-27 20:27:12 +00:00
process.env.NODE_ENV = 'production';
2017-09-26 22:54:26 +00:00
var cluster = require('cluster');
var http = require('http');
var https = require('https');
var path = require('path');
var express = require('express');
var app = express();
require('./server')(app);
2017-09-27 20:27:12 +00:00
var port = parseInt(process.env.PORT || 8080, 10);
2017-09-26 22:54:26 +00:00
if(port === 443) {
var fs = require('fs');
var credentials = {
2017-09-27 20:27:12 +00:00
key: fs.readFileSync(path.join(__dirname, 'ssl.key'), 'utf8'),
cert: fs.readFileSync(path.join(__dirname, 'ssl.crt'), 'utf8'),
ca: fs.readFileSync(path.join(__dirname, 'ssl.ca'), 'utf8').split('\n\n')
2017-09-26 22:54:26 +00:00
};
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(port, null, function() {
console.log('HTTPS server started: https://localhost');
});
port = 80;
}
var httpServer = http.createServer(app);
httpServer.listen(port, null, function() {
console.log('HTTP server started: http://localhost:' + port);
});