model/persistence.js
function(force, callback) {

        // Don't start if we're waiting for it to finish starting already.
        var should = !this._isStartingUp;

        // Don't start if we're outside the schedule, unless requested by the console.
        should = should && (this._shouldBeRunning() || force === true);

        // Don't start if it's already running.
        should = should && !this.processId();

        // Don't start if there's no start command.
        should = should && this.get('launchCommand');

        if (!should) {
            return;
        }

        if (this.get('startupTimeout')) {
            this._isStartingUp = true;
        }

        if (this.processId()) {
            // It's already running.
            this._isStartingUp = false;
            if (callback) {
                callback(true);
            }

            return;
        }

        this._lastHeart = null;
        this._firstHeart = null;
        this._startupCallback = callback;

        var parts = this._parseCommand(this.get('launchCommand'));

        // Start the app.
        logger.info('App starting up.');
        this._appProcess = child_process.spawn(parts[0], parts.slice(1), {
            cwd: path.dirname(parts[0])
        })
            .on('exit', _.bind(function() {
                this._appProcess = null;
            }, this))
            .on('error', _.bind(function(err) {
                logger.error('Application could not be started. Is the launchCommand path correct?');
                this._appProcess = null;
            }, this));
        this._resetRestartTimeout(this.get('startupTimeout'));

        if (!this.get('sideCommand')) {
            return;
        }

        // Start the side process.
        parts = this._parseCommand(this.get('sideCommand'));
        this._sideProcess = child_process.spawn(parts[0], parts.slice(1), {
            cwd: path.dirname(parts[0])
        }).on('exit', _.bind(function() {
            this._sideProcess = null;
        }, this));
    }
function(force, callback) {

        // Don't start if we're waiting for it to finish starting already.
        var should = !this._isStartingUp;

        // Don't start if we're outside the schedule, unless requested by the console.
        should = should && (this._shouldBeRunning() || force === true);

        // Don't start if it's already running.
        should = should && !this.processId();

        // Don't start if there's no start command.
        should = should && this.get('launchCommand');

        if (!should) {
            return;
        }

        if (this.get('startupTimeout')) {
            this._isStartingUp = true;
        }

        if (this.processId()) {
            // It's already running.
            this._isStartingUp = false;
            if (callback) {
                callback(true);
            }

            return;
        }

        this._lastHeart = null;
        this._firstHeart = null;
        this._startupCallback = callback;

        var parts = this._parseCommand(this.get('launchCommand'));

        // Start the app.
        logger.info('App starting up.');
        this._appProcess = child_process.spawn(parts[0], parts.slice(1), {
            cwd: path.dirname(parts[0])
        })
            .on('exit', _.bind(function() {
                this._appProcess = null;
            }, this))
            .on('error', _.bind(function(err) {
                logger.error('Application could not be started. Is the launchCommand path correct?');
                this._appProcess = null;
            }, this));
        this._resetRestartTimeout(this.get('startupTimeout'));

        if (!this.get('sideCommand')) {
            return;
        }

        // Start the side process.
        parts = this._parseCommand(this.get('sideCommand'));
        this._sideProcess = child_process.spawn(parts[0], parts.slice(1), {
            cwd: path.dirname(parts[0])
        }).on('exit', _.bind(function() {
            this._sideProcess = null;
        }, this));
    }
function ( force , callback ) { // Don't start if we're waiting for it to finish starting already. var should = ! this . _isStartingUp ; // Don't start if we're outside the schedule, unless requested by the console. should = should && ( this . _shouldBeRunning ( ) || force === true ) ; // Don't start if it's already running. should = should && ! this . processId ( ) ; // Don't start if there's no start command. should = should && this . get ( 'launchCommand' ) ; if ( ! should ) { return ; } if ( this . get ( 'startupTimeout' ) ) { this . _isStartingUp = true ; } if ( this . processId ( ) ) { // It's already running. this . _isStartingUp = false ; if ( callback ) { callback ( true ) ; } return ; } this . _lastHeart = null ; this . _firstHeart = null ; this . _startupCallback = callback ; var parts = this . _parseCommand ( this . get ( 'launchCommand' ) ) ; // Start the app. logger . info ( 'App starting up.' ) ; this . _appProcess = child_process . spawn ( parts [ 0 ] , parts . slice ( 1 ) , { cwd : path . dirname ( parts [ 0 ] ) } ) . on ( 'exit' , _ . bind ( function ( ) { this . _appProcess = null ; } , this ) ) . on ( 'error' , _ . bind ( function ( err ) { logger . error ( 'Application could not be started. Is the launchCommand path correct?' ) ; this . _appProcess = null ; } , this ) ) ; this . _resetRestartTimeout ( this . get ( 'startupTimeout' ) ) ; if ( ! this . get ( 'sideCommand' ) ) { return ; } // Start the side process. parts = this . _parseCommand ( this . get ( 'sideCommand' ) ) ; this . _sideProcess = child_process . spawn ( parts [ 0 ] , parts . slice ( 1 ) , { cwd : path . dirname ( parts [ 0 ] ) } ) . on ( 'exit' , _ . bind ( function ( ) { this . _sideProcess = null ; } , this ) ) ; }
Start the app process.
Start the app process .