Skip to content

Commit

Permalink
Merge pull request #737 from radiodario/master
Browse files Browse the repository at this point in the history
added hostname configuration
  • Loading branch information
balupton committed Dec 18, 2013
2 parents bddbb35 + 5cb2016 commit b3a6f83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/lib/docpad.coffee
Expand Up @@ -913,6 +913,12 @@ class DocPad extends EventEmitterGrouped
# VMC_APP_PORT - CloudFoundry
port: null

# Hostname
# The hostname we want to listen on, which if null
# will be localhost, but we could specify 0.0.0.0 if we
# want to open up things
hostname: null

# Max Age
# The caching time limit that is sent to the client
maxAge: 86400000
Expand Down Expand Up @@ -1071,6 +1077,9 @@ class DocPad extends EventEmitterGrouped
getPort: ->
return @getConfig().port ? process.env.PORT ? process.env.VCAP_APP_PORT ? process.env.VMC_APP_PORT ? 9778

# Get the Hostname
getHostname: ->
return @getConfig().hostname ? process.env.HOSTNAME ? "localhost"

# =================================
# Initialization Functions
Expand Down Expand Up @@ -4593,6 +4602,7 @@ class DocPad extends EventEmitterGrouped
config = @config
locale = @getLocale()
port = @getPort()
hostname = @getHostname()

# Require
http = require('http')
Expand Down Expand Up @@ -4688,10 +4698,10 @@ class DocPad extends EventEmitterGrouped

# Listen
docpad.log 'debug', util.format(locale.serverStart, port, config.outPath)
opts.serverHttp.listen port, ->
opts.serverHttp.listen port, hostname, ->
# Log
address = opts.serverHttp.address()
serverHostname = if address.address is '0.0.0.0' then 'localhost' else address.address
serverHostname = address.address #if address.address is '0.0.0.0' then 'localhost' else address.address
serverPort = address.port
serverLocation = "http://#{serverHostname}:#{serverPort}/"
docpad.log 'info', util.format(locale.serverStarted, serverLocation, config.outPath)
Expand Down
4 changes: 3 additions & 1 deletion src/test/actions-test.coffee
Expand Up @@ -21,12 +21,14 @@ cliPath = pathUtil.join(docpadPath, 'bin', 'docpad')

# Params
port = 9779
baseUrl = "http://localhost:#{port}"
hostname = "0.0.0.0"
baseUrl = "http://#{hostname}:#{port}"
testWait = 1000*60*5 # five minutes

# Configure DocPad
docpadConfig =
port: port
hostname: hostname
rootPath: rootPath
logLevel: if (process.env.TRAVIS_NODE_VERSION? or '-d' in process.argv) then 7 else 5
skipUnsupportedPlugins: false
Expand Down

0 comments on commit b3a6f83

Please sign in to comment.