lib/group.js
function(ops, callback) {
        if(!callback) callback = function() { };

        //name of the script to run for supervisord
        if(!ops.name) ops.name = 'undefined';

        var supervisordName = this._name(ops.name);
        
        //script exists? split it apart
        if(ops.script) {
             ops.directory =  ops.script.split('.').length == 1 ? ops.script :path.dirname(ops.script);

            try {
                var package = JSON.parse(fs.readFileSync(ops.directory + '/package.json'));

                if(!package.main && package.bin) {
                    for(var binName in package.bin) {
                        ops.command = ops.directory + '/' + package.bin[binName];
                    }
                }
            } catch(e) {
                
            }
            
            if(!ops.command) ops.command = 'node ' + ops.script +' '+ (ops.args || []).join(' ');
        }

        var envStr;

        if(ops.environment) {
            var envBuffer = [];

            for(var property in ops.environment) {
                envBuffer.push(property + '=' + ops.environment[property]);
            }

            envStr = envBuffer.join(',');
        }


        //directory to script - chdir for supervisord
        //if(!ops.directory) return callback('directory is not provided');

        //the command to use for running supervisord
        if(!ops.command) return callback('command not provided');
        
        if(!ops.name) return callback('Name not provided');
         
        var self = this;


        var update = this._query({
            supervisordName: supervisordName, 
            name: ops.name,
            directory: ops.directory, 
            command: ops.command,
            environment: envStr,
            stdout_logfile: this.logsDir + '/' + supervisordName + '.log',
            stderr_logfile: this.logsDir + '/' + supervisordName + '-err.log'
        });
        
        //insert into the beet db 
        this._collection.update({ _id: this._id(supervisordName) }, { $set: update }, { upsert: true }, function(err, result){
            if(callback) callback(err, result);
        });
    }
function(ops, callback) {
        if(!callback) callback = function() { };

        //name of the script to run for supervisord
        if(!ops.name) ops.name = 'undefined';

        var supervisordName = this._name(ops.name);
        
        //script exists? split it apart
        if(ops.script) {
             ops.directory =  ops.script.split('.').length == 1 ? ops.script :path.dirname(ops.script);

            try {
                var package = JSON.parse(fs.readFileSync(ops.directory + '/package.json'));

                if(!package.main && package.bin) {
                    for(var binName in package.bin) {
                        ops.command = ops.directory + '/' + package.bin[binName];
                    }
                }
            } catch(e) {
                
            }
            
            if(!ops.command) ops.command = 'node ' + ops.script +' '+ (ops.args || []).join(' ');
        }

        var envStr;

        if(ops.environment) {
            var envBuffer = [];

            for(var property in ops.environment) {
                envBuffer.push(property + '=' + ops.environment[property]);
            }

            envStr = envBuffer.join(',');
        }


        //directory to script - chdir for supervisord
        //if(!ops.directory) return callback('directory is not provided');

        //the command to use for running supervisord
        if(!ops.command) return callback('command not provided');
        
        if(!ops.name) return callback('Name not provided');
         
        var self = this;


        var update = this._query({
            supervisordName: supervisordName, 
            name: ops.name,
            directory: ops.directory, 
            command: ops.command,
            environment: envStr,
            stdout_logfile: this.logsDir + '/' + supervisordName + '.log',
            stderr_logfile: this.logsDir + '/' + supervisordName + '-err.log'
        });
        
        //insert into the beet db 
        this._collection.update({ _id: this._id(supervisordName) }, { $set: update }, { upsert: true }, function(err, result){
            if(callback) callback(err, result);
        });
    }
function ( ops , callback ) { if ( ! callback ) callback = function ( ) { } ; //name of the script to run for supervisord if ( ! ops . name ) ops . name = 'undefined' ; var supervisordName = this . _name ( ops . name ) ; //script exists? split it apart if ( ops . script ) { ops . directory = ops . script . split ( '.' ) . length == 1 ? ops . script : path . dirname ( ops . script ) ; try { var package = JSON . parse ( fs . readFileSync ( ops . directory + '/package.json' ) ) ; if ( ! package . main && package . bin ) { for ( var binName in package . bin ) { ops . command = ops . directory + '/' + package . bin [ binName ] ; } } } catch ( e ) { } if ( ! ops . command ) ops . command = 'node ' + ops . script + ' ' + ( ops . args || [ ] ) . join ( ' ' ) ; } var envStr ; if ( ops . environment ) { var envBuffer = [ ] ; for ( var property in ops . environment ) { envBuffer . push ( property + '=' + ops . environment [ property ] ) ; } envStr = envBuffer . join ( ',' ) ; } //directory to script - chdir for supervisord //if(!ops.directory) return callback('directory is not provided'); //the command to use for running supervisord if ( ! ops . command ) return callback ( 'command not provided' ) ; if ( ! ops . name ) return callback ( 'Name not provided' ) ; var self = this ; var update = this . _query ( { supervisordName : supervisordName , name : ops . name , directory : ops . directory , command : ops . command , environment : envStr , stdout_logfile : this . logsDir + '/' + supervisordName + '.log' , stderr_logfile : this . logsDir + '/' + supervisordName + '-err.log' } ) ; //insert into the beet db  this . _collection . update ( { _id : this . _id ( supervisordName ) } , { $set : update } , { upsert : true } , function ( err , result ) { if ( callback ) callback ( err , result ) ; } ) ; }
addes a process to a given group
addes a process to a given group