add command line arguments

This commit is contained in:
Asraelite 2016-03-29 13:45:23 +01:00
parent 4f42723f4a
commit 1160466cf9
13 changed files with 129 additions and 7 deletions

View file

@ -13,7 +13,7 @@ class Room {
this.teamB = new Set();
this.world = new World(this);
this.name = (Math.random() * 100000 | 0).toString(36);
this.tps = 60;
this.tps = 5;
this.idGenerator = (function*() {
let i = 0;

View file

@ -1,5 +1,7 @@
'use strict';
const commander = require('commander');
const GameServer = require('./game/');
const WebServer = require('./web/');
const ServerInterface = require('./interface.js');
@ -10,6 +12,17 @@ class WingbaseServer extends ServerInterface {
constructor() {
super();
let port = process.env.PORT || 8080;
commander
.version(packageJson.version)
.option('-d, --development', 'run in development mode')
.option('-p, --port [port]', 'specify port to use', port)
.parse(process.argv);
this.args = commander;
console.log(commander.port);
process.on('SIGINT', this.stop.bind(this));
}

View file

@ -2,6 +2,8 @@
const express = require('express');
const http = require('http');
const nib = require('nib');
const stylus = require('stylus');
const minify = require('./minify.js');
@ -12,14 +14,24 @@ class WebServer {
}
start() {
this.appServer.listen(process.env.PORT || 8080);
this.appServer.listen(wingbase.args.port);
let app = this.app;
app.set('views', './public/views');
app.set('views', 'public/views');
app.set('view engine', 'jade');
app.engine('jade', require('jade').__express);
app.use(stylus.middleware({
src: 'public/stylus',
dest: 'public/static/css',
compile: (str, path) => {
return stylus(str)
.set('filename', path)
.use(nib())
}
}));
app.get('/wingbase.min.js', (req, res) => {
minify(result => {
res.contentType('wingbase.min.js');