Permalink
Browse files

Merge pull request #319 from alejandromg/master

[REV] Multiple node.js versions at nodester
  • Loading branch information...
2 parents 0d8c488 + e2bd12a commit b8bed7b168a78302b4d0dd26c94d9a649191f979 @nodester committed Mar 3, 2012
Showing with 544 additions and 149 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 README.md
  3. +11 −2 app.js
  4. +59 −0 bin/create_versions.js
  5. +294 −0 install.md
  6. +0 −115 install.txt
  7. +44 −12 lib/app.js
  8. +52 −8 lib/lib.js
  9. +15 −1 lib/npm.js
  10. +1 −1 lib/unionfs.js
  11. +30 −2 scripts/chroot_runner.js
  12. +34 −7 scripts/launch_chrooted_app.js
  13. +1 −0 var/proxy_table.json
View
@@ -7,3 +7,5 @@ bin/.nodester.config
.DS_Store
*.log
node_modules
+test
+*.un~
View
@@ -29,7 +29,7 @@ http://youtu.be/jwsP1Ejv-_w
## Installing Nodester on Amazon EC2, Rackspace, GoGrid, or your own datacenter services
-Please see install.txt for setup instructions (https://github.com/nodester/nodester/blob/master/install.txt)
+Please see install.md for setup instructions (https://github.com/nodester/nodester/blob/master/install.md)
## Testing Locally
View
13 app.js
@@ -40,7 +40,7 @@ myapp.error(function (err, req, res, next) {
res.sendfile(__dirname + '/public/404.html');
// res.render('404.html');
} else {
- res.sendfile('/public/500.html');
+ res.sendfile(__dirname + '/public/500.html');
// res.render('500.html');
}
});
@@ -49,7 +49,7 @@ myapp.error(function (err, req, res, next) {
// Routes
// Homepage
myapp.get('/', function (req, res, next) {
- res.render('index.html');
+ res.sendfile(__dirname +'/public/index.html');
});
myapp.get('/api', function (req, res, next) {
@@ -153,6 +153,15 @@ myapp.get('/applogs/:appname', middle.authenticate, middle.authenticate_app, app
// curl -u GET -u "testuser:123" -d "appname=test" http://localhost:4001/env
// curl -u PUT -u "testuser:123" -d "appname=test&key=NODE_ENV&value=production" http://localhost:4001/env
// curl -u DELETE -u "testuser:123" -d "appname=test&key=NODE_ENV" http://localhost:4001/env
+
+// Get info about available versions.
+// NOTE: I think putting these at /env/ is a good choice since they are environment settings
+// curl -XGET http://localhost:4001/env/version
+myapp.get('/env/version', app.env_version);
+// Get info about a specific version and see if it's installed
+// without need of basic auth
+// curl -XGET http://localhost:4001/env/:version
+myapp.get('/env/version/:version', app.check_env_version);
myapp.get('/env/:appname', middle.authenticate, middle.authenticate_app, app.env_get);
myapp.put('/env', middle.authenticate, middle.authenticate_app, app.env_put);
myapp.del('/env/:appname/:key', middle.authenticate, middle.authenticate_app, app.env_delete);
View
@@ -0,0 +1,59 @@
+#!/usr/bin/env node
+
+var exec = require('child_process').spawn;
+
+// Install all the versions
+// But ignore these because they are too old
+var ignore = [0,0.1,0.2,0.3];
+
+var installVersion = function(_version){
+ console.log('[INFO] This may take a while, go and grab some coffee');
+ // Like sudoer?
+ var execute = function(v){
+ console.log('[INFO] installing node-v'+ v.trim());
+ var installprocess = exec('n ' + v.trim());
+ installprocess.stderr.on('end', function(data){
+ console.log('[INFO] stderr node-v'+v.trim()+' :' + data);
+ });
+ installprocess.stdout.on('end', function(data){
+ console.log('[INFO] stdout Installed node-v'+v.trim()+' :' +data);
+ });
+ installprocess.on('exit', function(code) {
+ if (code !== 0) {
+ console.log('Failed: ' + v.trim());
+ }
+ });
+ };
+ if (_version){
+ execute(_version);
+ } else {
+ exec('n', function(error,list){
+ if (!error) {
+ exec('n list', function(e,d){
+ if (!e) {
+ var installed = list.split('\n');
+ d.split('\n').forEach(function(v){
+ var version = parseFloat(v.trim());
+ if (!isNaN(version) && ignore.indexOf(version) === -1 &&
+ list.indexOf(v) === -1) {
+ execute(v);
+ }
+ });
+ } else {
+ console.log('[ERROR] getting list of node versions');
+ }
+ });
+ } else {
+ console.log('[ERROR] maybe `n` is not installed');
+ }
+ });
+ }
+};
+
+// TO execute this module you need to pass the param --run
+if (process.argv[2] === '--run') installVersion();
+if (process.argv[2] === '-v' && !isNaN(parseInt(process.arg[3] || ''))) {
+ installVersion(process.arg[3]);
+}
+
+module.exports = exports = installVersion;
Oops, something went wrong.

0 comments on commit b8bed7b

Please sign in to comment.