Skip to content

Commit

Permalink
Merge pull request #839 from todd/express_port
Browse files Browse the repository at this point in the history
Add Support for EXPRESS_PORT Variable
  • Loading branch information
technicalpickles committed Mar 7, 2015
2 parents b43602b + 9740039 commit 9b3ab0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/scripting.md
Expand Up @@ -418,7 +418,7 @@ module.exports = (robot) ->

## HTTP Listener

Hubot includes support for the [express](http://expressjs.com/guide.html) web framework to serve up HTTP requests. It listens on the port specified by the `PORT` environment variable, and defaults to 8080. An instance of an express application is available at `robot.router`. It can be protected with username and password by specifying `EXPRESS_USER` and `EXPRESS_PASSWORD`. It can automatically serve static files by setting `EXPRESS_STATIC`.
Hubot includes support for the [express](http://expressjs.com/guide.html) web framework to serve up HTTP requests. It listens on the port specified by the `EXPRESS_PORT` or `PORT` environment variables (preferred in that order) and defaults to 8080. An instance of an express application is available at `robot.router`. It can be protected with username and password by specifying `EXPRESS_USER` and `EXPRESS_PASSWORD`. It can automatically serve static files by setting `EXPRESS_STATIC`.

The most common use of this is for providing HTTP end points for services with webhooks to push to, and have those show up in chat.

Expand Down
4 changes: 3 additions & 1 deletion src/robot.coffee
Expand Up @@ -275,6 +275,8 @@ class Robot
user = process.env.EXPRESS_USER
pass = process.env.EXPRESS_PASSWORD
stat = process.env.EXPRESS_STATIC
port = process.env.EXPRESS_PORT or process.env.PORT or 8080
address = process.env.EXPRESS_BIND_ADDRESS or process.env.BIND_ADDRESS or '0.0.0.0'

express = require 'express'

Expand All @@ -290,7 +292,7 @@ class Robot
app.use express.static stat if stat

try
@server = app.listen(process.env.PORT || 8080, process.env.BIND_ADDRESS || '0.0.0.0')
@server = app.listen(port, address)
@router = app
catch err
@logger.error "Error trying to start HTTP server: #{err}\n#{err.stack}"
Expand Down

0 comments on commit 9b3ab0e

Please sign in to comment.