Building a Real-Time Activity Stream on Cloud Foundry with Node.js, Redis and MongoDB--Part II #1

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
1 participant
@ciberch
Owner

ciberch commented Jun 5, 2012

This is the source code for the tutorial on building an Activity Stream Part 2 http://blog.cloudfoundry.com/2012/06/05/node-activity-streams-app-2/

Once you are done making these changes you can easily increase the number of instances

Example:

vmc instances node-express-start 4
@@ -6,6 +6,9 @@
"engines" : ["node"],
"repository" : { "type":"git", "url":"http://github.com/mape/node-express-boilerplate" },
"dependencies" : {
+ "activity-streams-mongoose": ">=0.0.11",
+ "mongoose": "",
+ "underscore": "",

This comment has been minimized.

@ciberch

ciberch Jun 5, 2012

Owner

Run npm install after these changes

@ciberch

ciberch Jun 5, 2012

Owner

Run npm install after these changes

@@ -47,5 +50,11 @@ if (cf.cloud) {
settings.redisOptions.host = redisConfig.hostname;
settings.redisOptions.pass = redisConfig.password;
}
+
+ if (cf.mongodb['mongo-asms']) {

This comment has been minimized.

@ciberch

ciberch Jun 5, 2012

Owner

Locally you need to start running mongo. On Cloud Foundry just do

vmc create-service mongodb mongo-asms
vmc bind-service mongo-asms node-express-start # Or whatever the name is of your app
@ciberch

ciberch Jun 5, 2012

Owner

Locally you need to start running mongo. On Cloud Foundry just do

vmc create-service mongodb mongo-asms
vmc bind-service mongo-asms node-express-start # Or whatever the name is of your app
- client.on('disconnect', function() { console.log('disconnect'); });
+ client.on('disconnect', function() {
+ console.log('********* disconnect');
+ asmsServer.unsubscribe(desiredStream);

This comment has been minimized.

@ciberch

ciberch Jun 5, 2012

Owner

Avoid memory leaks by unsubscribing from Redis

@ciberch

ciberch Jun 5, 2012

Owner

Avoid memory leaks by unsubscribing from Redis

+ socketIoClient.on('message', function(json) {
+ var doc = JSON.parse(json);
+ if (doc) {
+ var msg = doc.actor.displayName + " " + doc.title + " " + doc.object.displayName;

This comment has been minimized.

@ciberch

ciberch Jun 5, 2012

Owner

Now we have a full activity so we can use its properties to build a more meaningful message

On Part 3 we will see how to use jade templates server side and client side

@ciberch

ciberch Jun 5, 2012

Owner

Now we have a full activity so we can use its properties to build a more meaningful message

On Part 3 we will see how to use jade templates server side and client side

+ $li.remove();
+ }, 5000);
+
+ if (doc.verb == "connect") {

This comment has been minimized.

@ciberch

ciberch Jun 5, 2012

Owner

Doing something semi interesting with the different activities

@ciberch

ciberch Jun 5, 2012

Owner

Doing something semi interesting with the different activities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment