Skip to content

Commit

Permalink
Changed filename back to start.js + added missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
explodingcamera committed May 31, 2016
1 parent 1934533 commit 1456006
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 115 deletions.
74 changes: 0 additions & 74 deletions app.js

This file was deleted.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
},
"homepage": "https://github.com/musiqpad/mqp-server#readme",
"scripts": {
"start": "node ./start.js"
"start": "node ./mqp.js start",
"stop": "node ./mqp.js stop",
"restart": "node ./mqp.js restart",
"log": "node ./mqp.js log",
"update": "node ./mqp.js update"
},
"dependencies": {
"basic-logger": "^0.4.4",
"chalk": "^1.0.0",
"clean-css": "^3.4.9",
"daemon": "^1.1.0",
"deasync": "^0.1.4",
"download-git-repo": "^0.1.2",
"durationjs": "^1.1.1",
"express": "^4.13.3",
"extend": "^3.0.0",
"file-tail": "^0.3.0",
"forever": "^0.15.1",
"leveldown": "^1.4.3",
"leveldown": "1.4.4",
"levelup": "^1.3.1",
"mongodb": "^2.1.16",
"mysql": "^2.10.2",
Expand All @@ -36,7 +43,6 @@
"update-notifier": "^0.7.0",
"ws": "^1.0.1",
"xoauth2": "^1.1.0",
"boxen": "^0.5.1",
"chalk": "^1.0.0"
"yesno": "0.0.1"
}
}
51 changes: 25 additions & 26 deletions start.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,12 @@ var log = new(require('basic-logger'))({
prefix: "SocketServer"
});
var path = require('path');
var updateNotifier = require('update-notifier');
var pkg = require('./package.json');
var boxen = require('boxen');
var chalk = require('chalk');

if(!config.setup){
log.error("Please, setup your server by editing the 'serverconfig.js' file");
return;
}

function checkForUpdates() {
var notifier = updateNotifier({
pkg,
updateCheckInterval: 0
});
if(notifier.update) {
var message = '\n' + boxen('Update available ' + chalk.dim(notifier.update.current) + chalk.reset(' → ') + chalk.green(notifier.update.latest), {
padding: 1,
margin: 1,
borderColor: 'yellow',
borderStyle: 'round'
});
console.log(message);
}
}

setInterval(function () {
checkForUpdates()
}, 1000 * 60 * 60 * 2)

checkForUpdates()

var server = null;

var webConfig = '// THIS IS AN AUTOMATICALLY GENERATED FILE\n\nvar config=JSON.parse(\'' + JSON.stringify(
Expand Down Expand Up @@ -73,3 +47,28 @@ process.on('exit', socketServer.gracefulExit);

//catches ctrl+c event
process.on('SIGINT', socketServer.gracefulExit);

function fileExistsSync() {
var exists = false;
try {
exists = fs.statSync(path);
} catch(err) {
exists = false;
}

return !!exists;
}

if(process.argv[2] === "--daemon") {
if (fileExistsSync(__dirname + '/pidfile')) {
try {
var pid = fs.readFileSync(__dirname + '/pidfile', { encoding: 'utf-8' });
process.kill(pid, 0);
process.exit();
} catch (e) {
fs.unlinkSync(__dirname + '/pidfile');
}
}

fs.writeFile(__dirname + '/pidfile', process.pid);
}
18 changes: 8 additions & 10 deletions webserver/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ var socketServer = null;

if (config.certificate && config.certificate.key && config.certificate.cert){
server = https.createServer(config.certificate, app);
if(config.webServer.redirectHTTP && config.webServer.redirectPort != ''){
if(config.webServer.redirectHTTP && config.webServer.redirectPort != '')
server2 = http.createServer(app);
}
}else{
server = http.createServer(app);
}

//var server = http.createServer(app);

else {
server = http.createServer(app);
}

app.use(function(req, res, next) {
if(!req.secure && config.webServer.redirectHTTP) {
Expand All @@ -32,9 +29,10 @@ app.use(function(req, res, next) {
app.use(express.static(path.resolve(__dirname, 'public')));
app.use('/pads', express.static(path.resolve(__dirname, 'public')));
app.get('/config', function(req, res) {
res.send(fs.readFileSync(__dirname + '/public/lib/js/webconfig.js'));
res.setHeader("Content-Type", "application/javascript");
res.send(fs.readFileSync(__dirname + '/public/lib/js/webconfig.js'));
});
app.get('/api/room', function(req,res){
app.get('/api/room', function(req, res) {
var roomInfo = {
"slug": config.room.slug,
"name": config.room.name,
Expand Down Expand Up @@ -62,4 +60,4 @@ var setSocketServer = function(ss){
};


module.exports = {app: app, server: server, server2: server2, setSocketServer: setSocketServer};
module.exports = {app: app, server: server, server2: server2, setSocketServer: setSocketServer};

0 comments on commit 1456006

Please sign in to comment.