beginning refactor for production server hosting

This commit is contained in:
Josh Burman 2019-03-31 03:17:50 -04:00
parent 075bb2579c
commit 2ff0b7fa9f

View File

@ -16,25 +16,25 @@ import ClientBase from './clients/clientBase';
import MHSClient from './clients/sites/mhsClient'; import MHSClient from './clients/sites/mhsClient';
if (app.environment == 'development') { // if (app.environment == 'development') {
var privateKey = fs.readFileSync(app.privateKey, 'utf8'); // var privateKey = fs.readFileSync(app.privateKey, 'utf8');
var certificate = fs.readFileSync(app.certificate, 'utf8'); // var certificate = fs.readFileSync(app.certificate, 'utf8');
var options = {key: privateKey, cert: certificate, hostname: app.hostname}; // var options = {key: privateKey, cert: certificate, hostname: app.hostname};
const application = express(); // const application = express();
const server = https.createServer(options, application); // const server = https.createServer(options, application);
var wss = new WebSocket.Server({ server: server, maxPayload:250000, host: app.hostname }); // var wss = new WebSocket.Server({ server: server, maxPayload:250000, host: app.hostname });
application.use(express.json()); // application.use(express.json());
application.use('', routes); // application.use('', routes);
server.listen(app.port, () => { // server.listen(app.port, () => {
console.log(`Braid v${app.version} is running!\n`); // console.log(`Braid v${app.version} is running!\n`);
logger.accessLog.info(`Braid v${app.version} is running!\n`); // logger.accessLog.info(`Braid v${app.version} is running!\n`);
}); // });
} else { // } else {
var wss = new WebSocket.Server({ noServer: true, maxPayload:250000, host: app.hostname }); var wss = new WebSocket.Server({ maxPayload:250000, port: app.port });
} // }
let clientManager = new ClientManager(); let clientManager = new ClientManager();
let channelManager = new ChannelManager(); let channelManager = new ChannelManager();