Skip to content

Commit

Permalink
v5.1.0 added disable webhook worker option
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdemartini committed Jul 28, 2017
1 parent 4a0680a commit b6370eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
8 changes: 8 additions & 0 deletions command.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ options = [
env: 'WEBHOOK_NAMESPACE'
default: 'meshblu-webhooks'
help: 'Redis namespace for webhooks'
},
{
name: 'disable-webhook-worker'
type: 'bool'
env: 'DISABLE_WEBHOOK_WORKER'
default: false
help: 'option for disabling webhook worker.'
}
]

Expand Down Expand Up @@ -246,6 +253,7 @@ options = {
maxConnections: opts.max_connections
port: opts.meshblu_http_port
webhookWorker:
disable: opts.disable_webhook_worker
namespace: opts.webhook_namespace
redisUri: opts.redis_uri
queueName: opts.webhook_queue_name
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meshblu-server",
"version": "5.0.3",
"version": "5.1.0",
"description": "A bundled version of meshblu-core",
"main": "index.js",
"repository": {
Expand All @@ -19,7 +19,7 @@
"license": "MIT",
"dependencies": {
"async": "^2.5.0",
"coffee-script": "^1.12.6",
"coffee-script": "^1.12.7",
"dashdash": "^1.14.0",
"debug": "^2.6.8",
"meshblu-core-dispatcher": "^20.0.5",
Expand Down
36 changes: 23 additions & 13 deletions src/meshblu-core-runner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,52 @@ class MeshbluCoreRunner extends EventEmitter
constructor: (options) ->
@dispatcherWorker = new DispatcherWorker options.dispatcherWorker
@meshbluHttp = new MeshbluHttp options.meshbluHttp
@webhookWorker = new WebhookWorker options.webhookWorker
unless options.webhookWorker.disable
@webhookWorker = new WebhookWorker options.webhookWorker

catchErrors: =>
debug '->catchErrors'
@dispatcherWorker.catchErrors()

destroy: (callback) =>
debug '->destroy'
async.parallel [
@meshbluHttp.destroy,
@dispatcherWorker.stop
@webhookWorker.stop
], callback
tasks = []
tasks.push (next) =>
@meshbluHttp.destroy (error) =>
next error
tasks.push (next) =>
next()
@dispatcherWorker.stop (error) =>
throw error if error?
tasks.push (next) =>
return next() unless @webhookWorker?
@webhookWorker.stop (error) =>
next error

async.parallel tasks, callback

prepare: (callback) =>
debug '->prepare'
@dispatcherWorker.prepare(callback)
@dispatcherWorker.prepare callback

reportError: =>
debug '->reportError'
@dispatcherWorker.reportError arguments...

stop: (callback) =>
debug '->stop'
async.parallel [
@meshbluHttp.stop,
@dispatcherWorker.stop
@webhookWorker.stop
], callback
tasks = []
tasks.push @meshbluHttp.stop
tasks.push @dispatcherWorker.stop
tasks.push @webhookWorker.stop if @webhookWorker?
async.parallel tasks, callback

run: (callback) =>
debug '->run'
@dispatcherWorker.run (error) =>
@emit 'error', error if error?

@webhookWorker.start (error) =>
@webhookWorker?.start (error) =>
@emit 'error', error if error?

@meshbluHttp.run callback
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ coffee-script@>=1.6.2, coffee-script@^1.10.0, coffee-script@^1.11.1, coffee-scri
version "1.12.6"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.6.tgz#285a3f7115689065064d6bf9ef4572db66695cbf"

coffee-script@^1.12.7:
version "1.12.7"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.7.tgz#c05dae0cb79591d05b3070a8433a98c9a89ccc53"

colors@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"
Expand Down

0 comments on commit b6370eb

Please sign in to comment.