diff --git a/labs/bbb-callback/README.md b/labs/bbb-callback/README.md index fca5f9bf2a224a2799c9c37ff7819b72bca9db06..0db76024361cfd8ec6843bd5f09afe2e7a0bc1c6 100644 --- a/labs/bbb-callback/README.md +++ b/labs/bbb-callback/README.md @@ -245,9 +245,11 @@ make sudo make install ``` -2. Copy and edit the configuration file: `cp config_local.coffee.example config_local.coffee` +2. Install the dependencies: `npm install` -3. Run the application with: +3. Copy and edit the configuration file: `cp config_local.coffee.example config_local.coffee` + +4. Run the application with: ```bash node app.js @@ -267,35 +269,34 @@ make sudo make install ``` -2. Copy the entire webhooks directory to `/usr/local/bigbluebutton/bbb-webhooks` +2. Copy the entire webhooks directory to `/usr/local/bigbluebutton/bbb-webhooks` and cd into it. + +3. Install the dependencies: `npm install` -3. Copy and edit the configuration file to adapt to your server: `cp config_local.coffee.example config_local.coffee` +4. Copy and edit the configuration file to adapt to your server: `cp config_local.coffee.example config_local.coffee`. -4. Drop the nginx configuration file in its place: `cp config/webhooks.nginx /etc/bigbluebutton/nginx/`. +5. Drop the nginx configuration file in its place: `cp config/webhooks.nginx /etc/bigbluebutton/nginx/`. If you changed the port of the web server on your configuration file, you will have to edit it in `webhooks.nginx` as well. -5. Copy upstart's configuration file and make sure its permissions are ok: +6. Copy upstart's configuration file and make sure its permissions are ok: ```bash sudo cp config/upstart-bbb-webhooks.conf /etc/init/bbb-webhooks.conf sudo chown root:root /etc/init/bbb-webhooks.conf ``` -6. Copy monit's configuration file and make sure its permissions are ok: + Open the file and edit it. You might need to change things like the user used to run the application. + +7. Copy monit's configuration file and make sure its permissions are ok: ```bash sudo cp config/monit-bbb-webhooks /etc/monit/conf.d/bbb-webhooks sudo chown root:root /etc/monit/conf.d/bbb-webhooks ``` -7. Start the application using monit: - - ```bash -sudo monit monitor bbb-webhooks -sudo monit start bbb-webhooks - ``` + Open the file and edit it. You might need to change things like the port used by the application. - You can also use upstart to start/stop the application: +8. Start the application: ```bash sudo service bbb-webhooks start diff --git a/labs/bbb-callback/config/monit-bbb-webhooks b/labs/bbb-callback/config/monit-bbb-webhooks index 78ac9edabb28ea9fcebc0fb0d2129550d5cac1dd..18e1f1e445dfa9f30f84907d7d8312e48f0bcb91 100755 --- a/labs/bbb-callback/config/monit-bbb-webhooks +++ b/labs/bbb-callback/config/monit-bbb-webhooks @@ -9,4 +9,4 @@ check process bbb-webhooks with pidfile "/var/run/bbb-webhooks.pid" request /bigbluebutton/api/hooks/ping with timeout 30 seconds then restart - if 5 restarts within 5 cycles then timeout + # if 5 restarts within 5 cycles then timeout diff --git a/labs/bbb-callback/web_server.coffee b/labs/bbb-callback/web_server.coffee index d1a0a9f8bfa0aa1847e3d740d33fab524b7257d6..8124e93942432ac1a49f4ae198469fdde8038b53 100644 --- a/labs/bbb-callback/web_server.coffee +++ b/labs/bbb-callback/web_server.coffee @@ -24,12 +24,16 @@ module.exports = class WebServer _registerRoutes: -> # Request logger @app.all "*", (req, res, next) -> - console.log "<==", req.method, "request to", req.url, "from:", clientDataSimple(req) + unless fromMonit(req) + console.log "<==", req.method, "request to", req.url, "from:", clientDataSimple(req) next() @app.get "/bigbluebutton/api/hooks/create", @_validateChecksum, @_create @app.get "/bigbluebutton/api/hooks/destroy", @_validateChecksum, @_destroy @app.get "/bigbluebutton/api/hooks/list", @_validateChecksum, @_list + @app.get "/bigbluebutton/api/hooks/ping", (req, res) -> + res.write "bbb-webhooks up!" + res.end() _create: (req, res, next) -> urlObj = url.parse(req.url, true) @@ -84,8 +88,8 @@ module.exports = class WebServer hooks.forEach (hook) -> msg += "<hook>" msg += "<hookID>#{hook.id}</hookID>" - msg += "<callbackURL>#{hook.callbackURL}</callbackURL>" - msg += "<meetingID>#{hook.externalMeetingID}</meetingID>" unless hook.isGlobal() + msg += "<callbackURL><![CDATA[#{hook.callbackURL}]]></callbackURL>" + msg += "<meetingID><![CDATA[#{hook.externalMeetingID}]]></meetingID>" unless hook.isGlobal() msg += "</hook>" msg += "</hooks></response>" @@ -119,3 +123,7 @@ clientDataSimple = (req) -> # Cleans up a string with an XML in it removing spaces and new lines from between the tags. cleanupXML = (string) -> string.trim().replace(/>\s*/g, '>') + +# Was this request made by monit? +fromMonit = (req) -> + req.headers["user-agent"]? and req.headers["user-agent"].match(/^monit/)