Skip to content

Commit

Permalink
feat(server): add HOST environment variable support to bind to a spec…
Browse files Browse the repository at this point in the history
…ific network address
  • Loading branch information
vicchi committed Jul 16, 2020
1 parent 7827d2d commit f9d2517
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const morgan = require( 'morgan' );
const logger = require('pelias-logger').get('interpolation');
const through = require( 'through2' );
const _ = require('lodash');
const util = require( 'util' );

// optionally override port using env var
// optionally override port/host using env var
const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || undefined;

// help text
if( process.argv.length !== 4 ){
Expand Down Expand Up @@ -218,10 +220,10 @@ app.use('/demo', express.static('demo'));
// app.use('/builds', express.static('/data/builds'));
// app.use('/builds', directory('/data/builds', { hidden: false, icons: false, view: 'details' }));

app.listen( PORT, function() {
app.listen( PORT, HOST, function() {

// force loading of libpostal
analyze.street( 'test street' );

console.log( 'server listening on port', PORT );
console.log(util.format( 'server listening on %s:%s', HOST || '0.0.0.0', PORT ));
});

0 comments on commit f9d2517

Please sign in to comment.