From 0abf0055f26c2d7e45e64c1fb656346b6152cf4d Mon Sep 17 00:00:00 2001 From: FedeG Date: Tue, 13 Sep 2016 12:33:48 -0300 Subject: [PATCH 1/7] Close #10 - Add Dockerfile and dockerignore --- .dockerignore | 4 ++++ Dockerfile | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0400065 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +bower_components +.tmp +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8bc85ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:0.10 +MAINTAINER Federico Gonzalez + +RUN npm config set registry http://registry.npmjs.org +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +RUN npm install -g foreman && npm cache clean +ADD package.json /usr/src/app/ +RUN npm install && npm cache clean +ADD . /usr/src/app + +CMD [ "nf", "start" ] From 80c1508ae03133e1dcb36547d00dec238d46eda9 Mon Sep 17 00:00:00 2001 From: FedeG Date: Tue, 13 Sep 2016 12:33:50 -0300 Subject: [PATCH 2/7] #10 - Add docker documentation --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 081e780..811d198 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,11 @@ Lelylan Websockets is tested against Node 0.10.36. $ git clone git@github.com:lelylan/websockets.git && cd websockets $ npm install && npm install -g foreman $ nf start + +## Install with docker + + $ docker build --tag=websockets . + $ docker run -d -it --name websockets websockets When installing the service in production set [lelylan environment variables](https://github.com/lelylan/lelylan/blob/master/README.md#production). From 541d8cc41cafdf74b111090cbfc533e28bed9acc Mon Sep 17 00:00:00 2001 From: Federico Gonzalez Date: Mon, 5 Dec 2016 13:44:12 -0300 Subject: [PATCH 3/7] Add docker hub links and badges --- README.md | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 811d198..6931936 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,30 @@ Lelylan Websockets is tested against Node 0.10.36. ## Installation - $ git clone git@github.com:lelylan/websockets.git && cd websockets - $ npm install && npm install -g foreman - $ nf start +```bash +$ git clone git@github.com:lelylan/websockets.git && cd websockets +$ npm install && npm install -g foreman +$ nf start +``` ## Install with docker - $ docker build --tag=websockets . - $ docker run -d -it --name websockets websockets - +#### Badges +Docker image: [lelylanlab/websockets](https://hub.docker.com/r/lelylanlab/websockets/) + +[![](https://images.microbadger.com/badges/version/lelylanlab/websockets:latest.svg)](http://microbadger.com/images/lelylanlab/websockets:latest "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/lelylanlab/websockets:latest.svg)](http://microbadger.com/images/lelylanlab/websockets:latest "Get your own image badge on microbadger.com") + +### Use docker hub image +```bash +$ docker run -d -it --name websockets lelylanlab/websockets +``` + +### Generate local image +```bash +$ docker build --tag=websockets . +$ docker run -d -it --name websockets websockets +``` + When installing the service in production set [lelylan environment variables](https://github.com/lelylan/lelylan/blob/master/README.md#production). @@ -73,7 +88,6 @@ DashboardCtrl.$inject = ['$scope', 'AccessToken']; See [Lelylan Dashboard](http://lelylan.github.io/devices-dashboard-ng) code for a working implementation. - ## Contributing Fork the repo on github and send a pull requests with topic branches. @@ -81,9 +95,10 @@ Do not forget to provide specs to your contribution. ### Running specs - npm install - npm test - +```bash +npm install +npm test +``` ## Coding guidelines From 99e857ba85cff396b3e7503676027c2467905fec Mon Sep 17 00:00:00 2001 From: Federico Gonzalez Date: Mon, 6 Feb 2017 14:30:15 -0300 Subject: [PATCH 4/7] close #13 - remove location model --- .../components/lelylan-ng/lelylan-ng.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/assets/javascripts/components/lelylan-ng/lelylan-ng.js b/app/assets/javascripts/components/lelylan-ng/lelylan-ng.js index 1ba81fa..c28fab4 100644 --- a/app/assets/javascripts/components/lelylan-ng/lelylan-ng.js +++ b/app/assets/javascripts/components/lelylan-ng/lelylan-ng.js @@ -14,7 +14,6 @@ angular.module('lelylan', [ 'lelylan.property', 'lelylan.function', 'lelylan.status', - 'lelylan.location', 'lelylan.subscription', 'lelylan.category', @@ -116,20 +115,6 @@ client.factory('History', ['RequestWrapper', '$resource', 'lelylan.config', func 'use strict'; -var client = angular.module('lelylan.location', ['ngResource']); - -client.factory('Location', ['RequestWrapper', '$resource', 'lelylan.config', function(RequestWrapper, $resource, config) { - - var resource = $resource( - config.endpoint + '/locations/:id', - { id: '@id' }, - { update: { method: 'PUT' } } ); - - return RequestWrapper.wrap(resource, ['get', 'query', 'save', 'update', 'delete']); -}]); - -'use strict'; - var client = angular.module('lelylan.profile', ['ngResource']) client.factory('Profile', ['RequestWrapper', '$resource', 'lelylan.config', '$timeout', From 3e6757791716ef9f79ee4511b43f93713a99bbe8 Mon Sep 17 00:00:00 2001 From: Federico Gonzalez Date: Thu, 9 Mar 2017 17:21:50 -0300 Subject: [PATCH 5/7] Fix #15 - Configurate collection to capped --- lib/loop.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/loop.js b/lib/loop.js index 4ebde86..4fb197e 100644 --- a/lib/loop.js +++ b/lib/loop.js @@ -10,6 +10,7 @@ var Event = require('../app/models/jobs/event') // find the valid tokens associated to property-udpated events exports.execute = function(io) { + Event.db.db.executeDbCommand({"convertToCapped": "events", size: 10000000, max:1000}) Event.find({ websocket_processed: false, event: 'property-update' }) .tailable().stream().on('data', function(collection) { findTokens(collection, io) }); } From 26044029a9c2318f41f9d76bac8f66f82e13f752 Mon Sep 17 00:00:00 2001 From: Federico Gonzalez Date: Thu, 9 Mar 2017 17:25:29 -0300 Subject: [PATCH 6/7] Fix #16 - Change environment variable --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 769953e..57b5191 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,7 @@ var mongoose = require('mongoose') , express = require('express') , app = express() , server = require('http').createServer(app) - , io = require('socket.io').listen(server, { log: !!process.env.SCOKET_IO_LOG }) + , io = require('socket.io').listen(server, { origins: '*:*', log: !!process.env.SOCKET_IO_LOG }) , debug = require('debug')('lelylan'); From c5d028d129d32dbc1359dd0e480c0a8daf0410f0 Mon Sep 17 00:00:00 2001 From: Federico Gonzalez Date: Mon, 17 Apr 2017 18:20:06 -0300 Subject: [PATCH 7/7] Fix #17 - Add function for all events --- lib/loop.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/loop.js b/lib/loop.js index 4fb197e..a73ca5f 100644 --- a/lib/loop.js +++ b/lib/loop.js @@ -11,7 +11,7 @@ var Event = require('../app/models/jobs/event') // find the valid tokens associated to property-udpated events exports.execute = function(io) { Event.db.db.executeDbCommand({"convertToCapped": "events", size: 10000000, max:1000}) - Event.find({ websocket_processed: false, event: 'property-update' }) + Event.find({ websocket_processed: false }) .tailable().stream().on('data', function(collection) { findTokens(collection, io) }); } @@ -28,7 +28,10 @@ var findTokens = function(event, io) { // avoid the emitting for tokens that are not used from a web client if (io.sockets.manager.rooms['/' + room]) { - io.sockets.in(room).emit('update', { data: event.data, token: event.token }); + io.sockets.in(room).emit(event.event, { data: event.data, token: event.token }); + if (event.event === 'property-update') { + io.sockets.in(room).emit('update', { data: event.data, token: event.token }); + } } });