Allow specifying host to bind via BIND env var

This commit is contained in:
Jerko Steiner 2019-11-19 10:26:48 -03:00
parent e7eb6a08bd
commit d4e6dfbf60
2 changed files with 7 additions and 3 deletions

View File

@ -121,7 +121,8 @@ variables. For example:
- Change base URL: `PEERCALLS__BASE_URL=/test` - app will now be accessible at `localhost:3000/test`
- Enable HTTPS: `PEERCALLS__SSL='{"cert": "/path/to/cert.pem", "key": "/path/to/cert.key"}'`
- Disable HTTPS: `PEERCALLS__SSL=undefined`
- Listen on a different port: `PORT=3001`
- Listen on a different port: `PORT=3001` (default is `3000`)
- Bind to specific IP or hostname: `BIND=127.0.0.1`
See [config/default.yaml][config] for sample configuration.

View File

@ -8,8 +8,11 @@ import app from './server/app'
const debug = _debug('peercalls')
const port = process.env.PORT || 3000
app.listen(port, () => debug('Listening on: %s', port))
const port = parseInt(process.env.PORT || '') || 3000
const hostname = process.env.BIND
const server = app.listen(
port, hostname, () => debug('Listening on %s', server.address()))
process.on('SIGINT', () => process.exit())
process.on('SIGTERM', () => process.exit())