Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added hostname configuration #737

Merged
merged 1 commit into from
Dec 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this output 0.0.0.0 now when null/localhost is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually on my tests, it still outputs localhost, which is strange. Also on the current version, even if it's listening on 0.0.0.0 it's saying localhost, which made me think it wouldn't listen on all interfaces, i.e only on loopback. I think it'd be better if it outputs exactly what it is listening on?

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