stop(cb) {
    if (this.status === 'reload') {
      this.removeAllListeners('reloaded');
      this.removeAllListeners('reload_failed');
    }
    this.status = 'stopping';
    log.warn(FLAG_CHILD, `app_shutting_down : ${this.appId}`);
    // clearTimeout(this.readyTimeoutId);
    // this.readyTimeoutId = null;
    // clear retry timeout
    this.retryTimeoutId.forEach((timeout) => {
      clearTimeout(timeout);
    });
    // clean group message bind
    message.unbindGroupMessage(this.appId);
    this.send({
      action: 'offline'
    }, () => {
      let workers = _.assign({}, this.workers, this.oldWorkers);
      // clean workers ref
      this.oldWorkers = {};
      this.workers = {};
      // clean record
      this.errorExitCount = 0;
      this.errorExitRecord = [];
      async.each(workers, this._kill.bind(this), (err) => {
        if (err) {
          log.error(FLAG_CHILD, `app_stop_error : ${this.appId} `, err);
        }
        if (this.stdout) {
          this.stdout.end();
          this.stdout = null;
        }
        this.status = 'offline';
        this.removeSockFile();
        this.emit('stop');
        cb && cb(err);
      });
    });
  }
/**
   * stop all workers, this method should handler following situations:
   *   1. should stopping the apps which in starting states
   *   2. should work fine when app already stopped
   *   3. should waitting when if app is reloading
   */
stop all workers, this method should handler following situations:
1. should stopping the apps which in starting states
2. should work fine when app already stopped
3. should waitting when if app is reloading
stop all workers this method should handler following situations : 1 . should stopping the apps which in starting states 2 . should work fine when app already stopped 3 . should waitting when if app is reloading
stop(cb) {
    if (this.status === 'reload') {
      this.removeAllListeners('reloaded');
      this.removeAllListeners('reload_failed');
    }
    this.status = 'stopping';
    log.warn(FLAG_CHILD, `app_shutting_down : ${this.appId}`);
    this.retryTimeoutId.forEach((timeout) => {
      clearTimeout(timeout);
    });
    message.unbindGroupMessage(this.appId);
    this.send({
      action: 'offline'
    }, () => {
      let workers = _.assign({}, this.workers, this.oldWorkers);
      this.oldWorkers = {};
      this.workers = {};
      this.errorExitCount = 0;
      this.errorExitRecord = [];
      async.each(workers, this._kill.bind(this), (err) => {
        if (err) {
          log.error(FLAG_CHILD, `app_stop_error : ${this.appId} `, err);
        }
        if (this.stdout) {
          this.stdout.end();
          this.stdout = null;
        }
        this.status = 'offline';
        this.removeSockFile();
        this.emit('stop');
        cb && cb(err);
      });
    });
  }
stop ( cb ) { if ( this . status === 'reload' ) { this . removeAllListeners ( 'reloaded' ) ; this . removeAllListeners ( 'reload_failed' ) ; } this . status = 'stopping' ; log . warn ( FLAG_CHILD , ` ${ this . appId } ` ) ; this . retryTimeoutId . forEach ( ( timeout ) => { clearTimeout ( timeout ) ; } ) ; message . unbindGroupMessage ( this . appId ) ; this . send ( { action : 'offline' } , ( ) => { let workers = _ . assign ( { } , this . workers , this . oldWorkers ) ; this . oldWorkers = { } ; this . workers = { } ; this . errorExitCount = 0 ; this . errorExitRecord = [ ] ; async . each ( workers , this . _kill . bind ( this ) , ( err ) => { if ( err ) { log . error ( FLAG_CHILD , ` ${ this . appId } ` , err ) ; } if ( this . stdout ) { this . stdout . end ( ) ; this . stdout = null ; } this . status = 'offline' ; this . removeSockFile ( ) ; this . emit ( 'stop' ) ; cb && cb ( err ) ; } ) ; } ) ; }
stop all workers, this method should handler following situations:
   1. should stopping the apps which in starting states
   2. should work fine when app already stopped
   3. should waitting when if app is reloading
stop all workers this method should handler following situations : 1 . should stopping the apps which in starting states 2 . should work fine when app already stopped 3 . should waitting when if app is reloading
// clearTimeout(this.readyTimeoutId); // this.readyTimeoutId = null; // clear retry timeout // clean group message bind // clean workers ref // clean record