diff --git a/README.md b/README.md index 89193b1..17eefd7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Download and install dependencies: cd webapi-eca npm install -Get your [redis](http://redis.io/) instance up and running (and find the port for the config file below) or create your own `js/persistence.js`. +Get your [redis](http://redis.io/) instance up and running ( and find the port for the config file below ) or create your own `js/persistence.js`. Edit the configuration file: diff --git a/coffee/components-manager.coffee b/coffee/components-manager.coffee index b6733bf..be7a4c9 100644 --- a/coffee/components-manager.coffee +++ b/coffee/components-manager.coffee @@ -225,6 +225,8 @@ storeModule = ( user, oBody, modType, dbMod, callback ) => # dbMod.publish oBody.id callback answ +# Store a rule and inform everybody about it +# ------------------------------------------ storeRule = ( user, oBody, callback ) => # This is how a rule is stored in the database rule = @@ -244,22 +246,22 @@ storeRule = ( user, oBody, callback ) => db.linkRule rule.id, user.username # activate the rule db.activateRule rule.id, user.username - # if event module parameters were send, store them + # if event module parameters were sent, store them if oBody.eventparams epModId = rule.eventname.split( ' -> ' )[ 0 ] db.eventPollers.storeUserParams epModId, user.username, JSON.stringify oBody.eventparams oFuncArgs = oBody.eventfunctions - # if event function arguments were send, store them + # if event function arguments were sent, store them for id, args of oFuncArgs arr = id.split ' -> ' db.eventPollers.storeUserArguments user.username, rule.id, arr[ 0 ], arr[ 1 ], JSON.stringify args - # if action module params were send, store them + # if action module params were sent, store them oParams = oBody.actionparams for id, params of oParams db.actionInvokers.storeUserParams id, user.username, JSON.stringify params oFuncArgs = oBody.actionfunctions - # if action function arguments were send, store them + # if action function arguments were sent, store them for id, args of oFuncArgs arr = id.split ' -> ' db.actionInvokers.storeUserArguments user.username, rule.id, arr[ 0 ], arr[ 1 ], JSON.stringify args @@ -450,6 +452,7 @@ commandFunctions = # WEBHOOKS +# -------- create_webhook: ( user, oBody, callback ) -> answ = hasRequiredParams [ 'hookname' ], oBody if answ.code isnt 200 diff --git a/coffee/event-poller.coffee b/coffee/event-poller.coffee index 9ef67c2..c90d0f3 100644 --- a/coffee/event-poller.coffee +++ b/coffee/event-poller.coffee @@ -59,7 +59,7 @@ isRunning = true # Register disconnect action. Since no standalone mode is intended # the event poller will shut down process.on 'disconnect', () -> - log.info 'EP | Shutting down Event Poller' + log.warn 'EP | Shutting down Event Poller' isRunning = false # very important so the process doesnt linger on when the paren process is killed process.exit() diff --git a/coffee/webapi-eca.coffee b/coffee/webapi-eca.coffee index 4296cfc..07ae6c3 100644 --- a/coffee/webapi-eca.coffee +++ b/coffee/webapi-eca.coffee @@ -157,8 +157,6 @@ init = => @log.info 'RS | Initialzing DB' db args # > We only proceed with the initialization if the DB is ready - #TODO eventually we shouldn't let each module load its own persistence - #module, but hand this one through them via the args... db.isConnected ( err ) => db.selectDatabase parseInt( args[ 'db-select' ] ) || 0 if err @@ -192,6 +190,7 @@ init = => # - The keygen phrase, this has to be handled differently in the future! args[ 'keygen' ] ] + # Initialize the event poller with the required CLI arguments poller = cp.fork path.resolve( __dirname, nameEP ), cliArgs # after the engine and the event poller have been initialized we can @@ -203,7 +202,7 @@ init = => cm.addRuleListener ( evt ) -> poller.send evt @log.info 'RS | Initialzing http listener' - # The request handler passes certain requests to the module manager + # The request handler passes certain requests to the components manager args[ 'request-service' ] = cm.processRequest # We give the HTTP listener the ability to shutdown the whole system args[ 'shutdown-function' ] = shutDown diff --git a/examples/action-invokers/probinder.coffee b/examples/action-invokers/probinder.coffee index 033bfda..9c3b081 100644 --- a/examples/action-invokers/probinder.coffee +++ b/examples/action-invokers/probinder.coffee @@ -6,6 +6,7 @@ ProBinder ACTION INVOKER Global variables This module requires user-specific parameters: + - username - password ### diff --git a/examples/event-pollers/weather.coffee b/examples/event-pollers/weather.coffee index de8dd85..99b8b92 100644 --- a/examples/event-pollers/weather.coffee +++ b/examples/event-pollers/weather.coffee @@ -3,6 +3,7 @@ OpenWeather EVENT POLLER ------------------------ This module requires user-specific parameters: + - appid ### urlService = 'http://api.openweathermap.org/data/2.5/weather' diff --git a/gen_doc.sh b/gen_doc.sh index 099a488..d1ffaf5 100755 --- a/gen_doc.sh +++ b/gen_doc.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/env nodejs /* * # groc Documentation * Create the documentation to be displayed through the webserver. diff --git a/run_engine.sh b/run_engine.sh index af0258c..569382c 100755 --- a/run_engine.sh +++ b/run_engine.sh @@ -1,3 +1,3 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -node $DIR/js/webapi-eca | $DIR/node_modules/bunyan/bin/bunyan +nodejs $DIR/js/webapi-eca | $DIR/node_modules/bunyan/bin/bunyan diff --git a/unit_tests.sh b/unit_tests.sh index 6deb78f..b08375a 100755 --- a/unit_tests.sh +++ b/unit_tests.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/env nodejs process.chdir( __dirname ); var fs = require( 'fs' ), path = require( 'path' ),