Skip to content

Commit

Permalink
cleanup bin
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaosthu committed Dec 2, 2016
1 parent 69e2827 commit c3b4f68
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
22 changes: 13 additions & 9 deletions bin/unleash.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@

process.env.NODE_ENV = 'production';

const { publicFolder } = require('unleash-frontend');
const program = require('commander');
const unleash = require('../lib/server-impl.js');
const { createOptions } = require('../lib/options.js');
const serverImpl = require('../lib/server-impl.js');

program
.option('-p, --port <port>', 'The port you want to start unleash on')
.option('-d, --databaseUri <databaseUri>', 'The full databaseUri to connect to, including username and password')
.parse(process.argv);

unleash.start({
databaseUri: program.databaseUri || process.env.DATABASE_URL,
port: program.port || process.env.PORT || 4242,
publicFolder,
}).then(conf => {
console.log(`Unleash started on port:${conf.app.get('port')}`);
});
const userOpts = {};
if(program.databaseUri) {
userOpts.databaseUri = program.databaseUri;
}
if(program.port) {
userOpts.port = program.port;
}

serverImpl.start(createOptions(userOpts))
.then(conf => console.log(`Unleash started on http://localhost:${conf.app.get('port')}`))
.catch(console.err);

2 changes: 2 additions & 0 deletions lib/options.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';
const { publicFolder } = require('unleash-frontend');

const DEFAULT_OPTIONS = {
databaseUri: process.env.DATABASE_URL,
port: process.env.HTTP_PORT || process.env.PORT || 4242,
baseUriPath: process.env.BASE_URI_PATH || '',
serverMetrics: true,
publicFolder,
};

module.exports = {
Expand Down
3 changes: 1 addition & 2 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const unleash = require('./lib/server-impl');
const { publicFolder } = require('unleash-frontend');

unleash.start({ publicFolder });
unleash.start();

0 comments on commit c3b4f68

Please sign in to comment.