Skip to content

Commit

Permalink
refactor(remove clustering logic, reccomended to use PM2):
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Feb 12, 2016
1 parent e51b6a9 commit 514e85b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 51 deletions.
11 changes: 6 additions & 5 deletions bin/mockbin
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

'use strict'

var cluster = require('../cluster')
var app = require('../src')
var cmd = require('commander')
var pkg = require('../package.json')
var pkg = require('../package')

cmd
.version(process.env.npm_package_version)
.version(pkg.version)
.option('-p, --port <port>', 'HTTP server port', pkg.config.port)
.option('-q, --quiet', 'disable console logging', pkg.config.quiet)
.option('-r, --redis [dsn]', 'redis dsn', pkg.config.redis)
.option('-w, --workers <count>', 'number of cluster workers', pkg.config.workers)
.parse(process.argv)

cluster(cmd)
app(cmd, function () {
console.info('starting server on port: %d', cmd.port)
})
39 changes: 0 additions & 39 deletions cluster.js

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
"src",
"lib",
"Procfile",
"cluster.js",
"server.js"
],
"bugs": {
"url": "https://github.com/Mashape/mockbin/issues"
},
"config": {
"port": 8080,
"redis": "redis://127.0.0.1:6379",
"quiet": false,
"redis": "redis://127.0.0.1:6379",
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"scripts": {
"start": "node bin/mockbin",
"test": "mocha --recursive",
"pretest": "standard && echint",
"coverage": "istanbul cover --dir coverage _mocha -- --recursive --fgrep 'Request Validation' --invert --reporter dot",
Expand All @@ -68,7 +68,7 @@
"commander": "^2.8.1",
"compression": "^1.4.4",
"cookie-parser": "^1.3.5",
"debug": "^2.2.0",
"debug-log": "^1.0.0",
"dicer": "^0.2.4",
"dotenv": "^1.1.0",
"express": "^4.12.4",
Expand All @@ -86,4 +86,4 @@
"simple-xml": "0.0.9",
"yamljs": "^0.2.3"
}
}
}
16 changes: 15 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
'use strict'

require('./cluster')()
var app = require('./src')
var dotenv = require('dotenv')
var pkg = require('./package')

dotenv.config({ silent: true })

var options = {
port: process.env.MOCKBIN_PORT || pkg.config.port,
quiet: process.env.MOCKBIN_QUIET || pkg.config.quiet,
redis: process.env.MOCKBIN_REDIS || pkg.config.redis
}

app(options, function () {
console.info('starting server on port: %d', options.port)
})
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var compression = require('compression')
var cookieParser = require('cookie-parser')
var debug = require('debug')('mockbin')
var debug = require('debug-log')('mockbin')
var express = require('express')
var methodOverride = require('method-override')
var morgan = require('morgan')
Expand All @@ -22,7 +22,7 @@ module.exports = function (options, done) {
app.enable('view cache')
app.enable('trust proxy')
app.set('view engine', 'jade')
app.set('views', path.join(__dirname, '/views'))
app.set('views', path.join(__dirname, 'views'))
app.set('jsonp callback name', '__callback')

// add 3rd party middlewares
Expand Down

0 comments on commit 514e85b

Please sign in to comment.