Permalink
Browse files

[master] Fixed indentation & spell error in order to @mintplant feedback

  • Loading branch information...
1 parent f92c41a commit e2bd12a6fa0fc93b138139eaeff4bf17ad073d42 @alejandro alejandro committed Feb 29, 2012
Showing with 93 additions and 62 deletions.
  1. +1 −1 bin/proxy_start.sh
  2. +26 −3 install.md
  3. +19 −13 lib/app.js
  4. +11 −9 lib/lib.js
  5. +33 −33 scripts/chroot_runner.js
  6. +3 −3 scripts/launch_chrooted_app.js
View
@@ -1,4 +1,4 @@
- #!/bin/bash
+#!/bin/bash
cd `dirname $0`
View
@@ -29,7 +29,27 @@ The only thing that you need to setup your personal instance is `ssh` access- Li
## Installation:
-Nodester was/is build on node 0.4.x so we recommend to have as default version the 0.4.9 or any 0.4.x version installed in your server. First of all you'll need some packages to make nodester work, the only one that you need to manually install are node.js, npm, curl and forever as follows:
+Nodester was/is build on node 0.4.x so we recommend to have as default version the 0.4.9 or any 0.4.x version installed in your server. Since nodester is able to manage multiple versions of node.js, you can install `n` before node.js or after it. We recommend to install before node.js:
+
+ > git clone https://github.com/visionmedia/n.git
+ > cd n
+ > make
+ > make install
+
+Check if `n` is installed correctly, otherwise (inside `n` dir):
+
+ > sudo cp bin/n /usr/local/bin
+
+Then you can use `n` as a node.js version manager, like this:
+
+ > n 0.4.9 #which is currently used by nodester
+
+**note**: It's a good practice to install any node.js version as root.
+Then go to [here](#a)
+
+If you don't want to git#clone the repo, follow these instructions:
+
+First of all you'll need some packages to make nodester work, the only one that you need to manually install are node.js, npm, curl and forever as follows:
> Install node.js (0.4.x recommended) as you prefer (wget/pkg/git clone)
@@ -47,6 +67,9 @@ Then install again node 0.4.x as n child:
The `n` command will handle all the installation process from the version, this is done from this way, so we after can use `n use 0.4.x` as unique method to run application. Meanwhile you are install node again trough `n` setup the user and the permissions needed to run your personal instance of `nodester`.
+<a id="a" />
+### Create the environment
+
**Create a user and group to run nodester as (do this as root)**
> sudo su -
@@ -222,7 +245,7 @@ If you did all the steps correctly, you are ready to go, but first let's create
> mkdir -p nodester/var/
> echo '{"example.co":4001, "api.example.co":4001}' > nodester/var/proxy_table.json
-Also you migth want to chown the proxy_table to nodester:
+Also you might want to chown the proxy_table to nodester:
> sudo chown $USER -R nodester/var/proxy_table.json
@@ -268,4 +291,4 @@ Sidenotes:
**More info about the REST API: http://nodester.com/api.html#rest**
-Don't you like the REST API way? Try the [`nodester-cli`](http://github.com/nodester/nodester-cli).
+Don't like the REST API way? Try the [`nodester-cli`](http://github.com/nodester/nodester-cli).
View
@@ -599,20 +599,26 @@ module.exports = {
});
},
check_env_version: function(req, res, next){
- var version = req.param('version');
- // just avoiding potencial errors
- version = (version === undefined || version === null || version === '') ? '0.0.1': version;
- check_node_version(version, function(data){
- var msg = ['node-v'+ version + ' it\'s not available, for the moment'];
- if (data) {
- msg = ['node-v'+version+ ' it\'s available'];
- }
- res.json({
- version: version,
- status: data,
- msg: msg
+ var version = req.param('version') || false;
+ // just avoiding potential errors
+ if (version) {
+ check_node_version(version, function(data){
+ var msg = ['node-v'+ version + ' it\'s not available, for the moment'];
+ if (data) {
+ msg = ['node-v'+version+ ' it\'s available'];
+ }
+ res.json({
+ version: version,
+ status: data,
+ msg: msg
+ });
});
- });
+ } else {
+ res.json({
+ statusCode: 400, // Invalid data
+ msg: ['Invalid version, or not_found']
+ })
+ }
},
env_put: function (req, res, next) {
var appname = req.body.appname.toLowerCase();
View
@@ -311,15 +311,17 @@ var setup_unionfs_chroot = function (chroot_base, git_home, rw_folder, final_chr
exports.setup_unionfs_chroot = setup_unionfs_chroot;
var check_node_version = function(ver,cb){
- // just avoid this;
- ver = (ver === undefined || ver === null || ver == '') ? '0.0.1':ver;
- exec('n use ' + ver, function(e,d){
- if (e){
- cb(false);
- } else {
- cb(true);
- }
- });
+ if (ver){
+ exec('n use ' + ver, function(e,d){
+ if (e){
+ cb(false);
+ } else {
+ cb(true);
+ }
+ });
+ } else {
+ cb(false);
+ }
};
exports.check_node_version = check_node_version;
@@ -113,46 +113,46 @@ var myPid = daemon.start();
// and replace it with `package.json`
// I'm not a RegExp guru so this is my solution ;)
var packPath = args[0].split('/');
- packPath[packPath.length-1] = 'package.json';
- packPath = packPath.join('/');
+ packPath[packPath.length-1] = 'package.json';
+ packPath = packPath.join('/');
// we don't know what kind of package.json are we dealing with
try {
pack = JSON.parse(fs.readFileSync(packPath, 'utf8'));
} catch(e){
// Set default to the parent node version
pack['node'] = process.version;
}
- // What if the try/catch read the package but there is no `node`?
- var version = pack['node'] === undefined ? process.version : pack['node'];
- // n dir only handles number paths without v0.x.x => 0.x.x
- version = version.replace('v','').trim();
- if (node_versions.indexOf(version) !== -1) {
- // The spawn process only works with absolute paths, and by default n'd saved every
- // version of node in /usr/local/n/version
- child = spawn((path.extname(args[0]) == '.coffee'
- ? '/usr/bin/coffee'
- : '/usr/local/n/versions/' + version +'/bin/node'), args, {
- env: env
- });
- child.stdout.on('data', log_line.bind('stdout'));
- child.stderr.on('data', log_line.bind('stderr'));
- child.on('exit', function (code) {
- if (code > 0 && run_count > run_max) {
- log_line.call('Watcher', 'Error: Restarted too many times, bailing.', LOG_STDERR);
- clearInterval(child_watcher_timer);
- } else if (code > 0) {
- log_line.call('Watcher', 'Process died with exit code ' + code + '. Restarting...', LOG_STDERR);
- child = null;
- } else {
- log_line.call('Watcher', 'Process exited cleanly. Dieing.', LOG_STDERR);
- clearInterval(child_watcher_timer);
- }
- });
- } else {
- log_line.call('Watcher', 'Process exited cleanly. node.js Version:'+version + ' not avaiable', LOG_STDERR);
- clearInterval(child_watcher_timer);
- }
- };
+ // What if the try/catch read the package but there is no `node`?
+ var version = pack['node'] === undefined ? process.version : pack['node'];
+ // n dir only handles number paths without v0.x.x => 0.x.x
+ version = version.replace('v','').trim();
+ if (node_versions.indexOf(version) !== -1) {
+ // The spawn process only works with absolute paths, and by default n'd saved every
+ // version of node in /usr/local/n/version
+ child = spawn((path.extname(args[0]) == '.coffee'
+ ? '/usr/bin/coffee'
+ : '/usr/local/n/versions/' + version +'/bin/node'), args, {
+ env: env
+ });
+ child.stdout.on('data', log_line.bind('stdout'));
+ child.stderr.on('data', log_line.bind('stderr'));
+ child.on('exit', function (code) {
+ if (code > 0 && run_count > run_max) {
+ log_line.call('Watcher', 'Error: Restarted too many times, bailing.', LOG_STDERR);
+ clearInterval(child_watcher_timer);
+ } else if (code > 0) {
+ log_line.call('Watcher', 'Process died with exit code ' + code + '. Restarting...', LOG_STDERR);
+ child = null;
+ } else {
+ log_line.call('Watcher', 'Process exited cleanly. Dieing.', LOG_STDERR);
+ clearInterval(child_watcher_timer);
+ }
+ });
+ } else {
+ log_line.call('Watcher', 'Process exited cleanly. node.js Version:'+version + ' not avaiable', LOG_STDERR);
+ clearInterval(child_watcher_timer);
+ }
+ };
var child_watcher = function () {
if (child === null) {
start_child();
@@ -23,10 +23,10 @@ if (appdir.indexOf('package.json') !== -1 ) {
try {
packageJSON = JSON.parse(fs.readFileSync(path.join('/','package.json'),'utf8'));
} catch(exp) {
- packageJSON = {
- node:process.version
- }
+ packageJSON = {
+ node:process.version
}
+ }
}
// RUN status (true/false)

0 comments on commit e2bd12a

Please sign in to comment.