<?php

final class PhabricatorDaemonManagementStatusWorkflow
  extends PhabricatorDaemonManagementWorkflow {

  protected function didConstruct() {
    $this
      ->setName('status')
      ->setSynopsis(pht('Show daemon processes on this host.'));
  }

  public function execute(PhutilArgumentParser $args) {
    $process_refs = $this->getOverseerProcessRefs();

    if (!$process_refs) {
      $instance = $this->getInstance();
      if ($instance !== null) {
        $this->logInfo(
          pht('NO DAEMONS'),
          pht(
            'There are no running daemon processes for the current '.
            'instance ("%s").',
            $instance));
      } else {
        $this->writeInfo(
          pht('NO DAEMONS'),
          pht('There are no running daemon processes.'));
      }

      return 1;
    }

    $table = id(new PhutilConsoleTable())
      ->addColumns(
        array(
          'pid' => array(
            'title' => pht('PID'),
          ),
          'command' => array(
            'title' => pht('Command'),
          ),
        ));

    foreach ($process_refs as $process_ref) {
      $table->addRow(
        array(
          'pid' => $process_ref->getPID(),
          'command' => $process_ref->getCommand(),
        ));
    }

    $table->draw();

    return 0;
  }

}

<?php

final class PhabricatorDaemonManagementStatusWorkflow
  extends PhabricatorDaemonManagementWorkflow {

  protected function didConstruct() {
    $this
      ->setName('status')
      ->setSynopsis(pht('Show daemon processes on this host.'));
  }

  public function execute(PhutilArgumentParser $args) {
    $process_refs = $this->getOverseerProcessRefs();

    if (!$process_refs) {
      $instance = $this->getInstance();
      if ($instance !== null) {
        $this->logInfo(
          pht('NO DAEMONS'),
          pht(
            'There are no running daemon processes for the current '.
            'instance ("%s").',
            $instance));
      } else {
        $this->logInfo(
          pht('NO DAEMONS'),
          pht('There are no running daemon processes.'));
      }

      return 1;
    }

    $table = id(new PhutilConsoleTable())
      ->addColumns(
        array(
          'pid' => array(
            'title' => pht('PID'),
          ),
          'command' => array(
            'title' => pht('Command'),
          ),
        ));

    foreach ($process_refs as $process_ref) {
      $table->addRow(
        array(
          'pid' => $process_ref->getPID(),
          'command' => $process_ref->getCommand(),
        ));
    }

    $table->draw();

    return 0;
  }

}

Fix a bad call to "writeInfo()" in "bin/phd stop" with no PHABRICATOR_INSTANCE defined
Fix a bad call to "writeInfo()" in "bin/phd stop" with no PHABRICATOR_INSTANCE defined

Summary: See <https://discourse.phabricator-community.org/t/phd-status-calls-to-undefined-method-when-theres-no-instance/2918>. This call should be `logInfo()`.

Test Plan:
  - Purged `PHABRICATOR_INSTANCE` from my environment. In a Phacility development environment, it comes from loading `services/`.
  - Ran `bin/phd stop` with all daemons already stopped.
    - Before: bad call.
    - After: helpful error.
  - Ran some other `bin/phd start`, `bin/phd status`, etc., to kick the tires.
  - Grepped for remaining `writeInfo()` calls (found none).

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20649
