Skip to content
This repository has been archived by the owner on Oct 27, 2018. It is now read-only.

Commit

Permalink
Add option to disable http mode
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
Michael Cebrian committed Sep 30, 2015
1 parent c12964e commit 833364d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ to `/APP_ROOT/v1/send` on whichever port you specify.
```bash
# Install nodejs
# This assumes you're on a 64 bit machine
wget http://nodejs.org/dist/v0.10.19/node-v0.10.19-linux-x64.tar.gz
tar xvf node-v0.10.19-linux-x64.tar.gz
sudo ln -s `pwd`/node-v0.10.19-linux-x64/bin/{node,npm} /usr/local/bin/
wget https://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-x64.tar.gz
tar xvf node-v4.1.1-linux-x64.tar.gz
sudo ln -s `pwd`/node-v4.1.1-linux-x64/bin/{node,npm} /usr/local/bin/

# Grab a Bucky release
# You should use the latest release available at https://github.com/HubSpot/BuckyServer/releases
Expand Down Expand Up @@ -101,7 +101,14 @@ If you need more customization, you can write a module:

There are a few of types of modules:


- Server - Use to set properties of the Bucky Server
- port - Use to set the port that Bucky Server will listen to
- appRoot - Use to define the root of the endpoint
- https - Use to set options for running Bucky Server in https mode
- port - Use to specify the port for https, if not populated the http server port + 1
- options - Use to define the certificates for https. [List of all possible options](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
- For all options that accept a buffer you can use the path to the file and they'll be read in
- httpsOnly - If this flag is set to true then Bucky Server will not run in http mode
- Logger - Use to have Bucky log to something other than the console
- Config - Use to have Bucky pull config from somewhere other than the default file
- App - Use to do things when Bucky loads and/or on requests. Auth, monitoring initialization, etc.
Expand Down
15 changes: 8 additions & 7 deletions config/default.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
server:
port: 5999
appRoot: "/bucky"

# If the following values are set, bucky will run as https and parse the key and cert files
# Place the key and cert files in the BuckyServer directory with server.coffee

# If https options are set then bucky will also listen on https
# https:
# options:
# key: "key.pem"
# cert: "cert.pem"
# port: 5599
# See full list of options at: https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener
# options:
# key: "ssl/key.pem"
# cert: "ssl/cert.pem"
# If the following is set to true then bucky server will not run in http mode
# httpsOnly: true

statsd:
host: 'localhost'
Expand Down
22 changes: 15 additions & 7 deletions server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Q = require 'q'
_ = require 'underscore'
express = require 'express'
http = require 'http'

# Set cwd for config, and load config file
process.chdir __dirname
Expand Down Expand Up @@ -118,17 +119,24 @@ loadApp = (logger, loadedConfig) ->
app.get "#{ APP_ROOT }/v1/health-check", (req, res) ->
res.send('OK\n')

port = process.env.PORT ? loadedConfig.get('server.port').get() ? 5000
if loadedConfig.get('server.https.options').get() instanceof Object
https = require 'https'
fs = require 'fs'
httpsOptions = _.mapObject loadedConfig.get('server.https.options').get(), (v, k) ->
fs.readFileSync(v)
https.createServer(httpsOptions, app).listen port
else
app.listen port

logger.log 'Server listening on port %d in %s mode', port, app.settings.env
if _.isString(v)
try
fs.readFileSync(v)
catch
v
else
v
httpsPort = loadedConfig.get('server.https.port').get() ? (port + 1)
https.createServer(httpsOptions, app).listen httpsPort
logger.log "HTTPS Server listening on port %d in %s mode", httpsPort, app.settings.env
if loadedConfig.get('server.httpsOnly').get() is not true
port = process.env.PORT ? loadedConfig.get('server.port').get() ? 5000
http.createServer(app).listen port
logger.log 'HTTP Server listening on port %d in %s mode', port, app.settings.env

Q.when(loadLogger()).then (logger) ->

Expand Down

0 comments on commit 833364d

Please sign in to comment.