Skip to content

Commit

Permalink
Merge pull request #6446 from RocketChat/tutum-to-js
Browse files Browse the repository at this point in the history
Convert Tutum Package to JS
  • Loading branch information
engelgabriel authored Mar 23, 2017
2 parents 85d9443 + f5ca0cf commit 813d087
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
4 changes: 1 addition & 3 deletions packages/rocketchat-tutum/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ Package.describe({

Package.onUse(function(api) {
api.use('ecmascript');
api.use('coffeescript');
api.use('rocketchat:lib');

api.addFiles('startup.coffee', 'server');
api.addFiles('startup.js', 'server');
});

Npm.depends({
Expand Down
27 changes: 0 additions & 27 deletions packages/rocketchat-tutum/startup.coffee

This file was deleted.

25 changes: 25 additions & 0 deletions packages/rocketchat-tutum/startup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Examples
DOCKERCLOUD_REDIS_HOST=redis://:password@host:6379
DOCKERCLOUD_CLIENT_NAME=mywebsite
DOCKERCLOUD_CLIENT_HOST=mywebsite.dotcloud.com
*/

if (process.env.DOCKERCLOUD_REDIS_HOST != null) {
const redis = Npm.require('redis');

const client = redis.createClient(process.env.DOCKERCLOUD_REDIS_HOST);

client.on('error', err => console.log('Redis error ->', err));

client.del(`frontend:${process.env.DOCKERCLOUD_CLIENT_HOST}`);
client.rpush(`frontend:${process.env.DOCKERCLOUD_CLIENT_HOST}`, process.env.DOCKERCLOUD_CLIENT_NAME);

const port = process.env.PORT || 3000;
client.rpush(`frontend:${process.env.DOCKERCLOUD_CLIENT_HOST}`, `http://${process.env.DOCKERCLOUD_IP_ADDRESS.split('/')[0]}:${port}`);

// removes the redis entry in 90 seconds on a SIGTERM
process.on('SIGTERM', () => client.expire(`frontend:${process.env.DOCKERCLOUD_CLIENT_HOST}`, 90));

process.on('SIGINT', () => client.expire(`frontend:${process.env.DOCKERCLOUD_CLIENT_HOST}`, 90));
}

0 comments on commit 813d087

Please sign in to comment.