2013-07-23 21:11:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
|
|
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
|
|
|
|
const STATUS_UNKNOWN = 'unknown';
|
|
|
|
const STATUS_RUNNING = 'run';
|
|
|
|
const STATUS_DEAD = 'dead';
|
|
|
|
const STATUS_WAIT = 'wait';
|
Send graceful shutdown signals to daemons in Phabricator
Summary:
Fixes T5855. Adds a `--graceful N` flag to `phd stop` and `phd restart`.
`phd` will send SIGINT, wait `N` seconds, SIGTERM, wait 15 seconds, and SIGKILL. By default, `N` is 15.
Test Plan:
- Ran `bin/phd debug ...` and used `^C` to interrupt daemons. Saw graceful shutdown behavior, and abrupt termination on multiple `^C`.
- Ran `bin/phd start`, `bin/phd stop` and `bin/phd restart` with `--graceful` set to various things, notably `0`. Saw graceful shutdowns on the CLI and in the web UI. With `0`, abrupt shutdowns.
Reviewers: btrahan, hach-que
Reviewed By: hach-que
Subscribers: epriestley
Maniphest Tasks: T5855
Differential Revision: https://secure.phabricator.com/D10228
2014-08-12 05:18:31 +02:00
|
|
|
const STATUS_EXITING = 'exiting';
|
2013-07-23 21:11:34 +02:00
|
|
|
const STATUS_EXITED = 'exit';
|
|
|
|
|
|
|
|
protected $daemon;
|
|
|
|
protected $host;
|
|
|
|
protected $pid;
|
2015-02-23 20:26:38 +01:00
|
|
|
protected $daemonID;
|
2014-12-23 17:11:44 +01:00
|
|
|
protected $runningAsUser;
|
2013-07-23 21:11:34 +02:00
|
|
|
protected $argv;
|
2014-06-27 00:23:22 +02:00
|
|
|
protected $explicitArgv = array();
|
2013-07-23 21:11:34 +02:00
|
|
|
protected $status;
|
|
|
|
|
2015-01-13 20:47:05 +01:00
|
|
|
protected function getConfiguration() {
|
2013-07-23 21:11:34 +02:00
|
|
|
return array(
|
|
|
|
self::CONFIG_SERIALIZATION => array(
|
|
|
|
'argv' => self::SERIALIZATION_JSON,
|
Unify the local and global view for `./bin/phd status`.
Summary:
Ref T4209. Unifies the local (`./bin/phd status`) and global (`./bin/phd status --all`) view into a single table. This generally makes it easy to administer daemons running across multiple hosts.
Depends on D9606.
Test Plan:
```
> sudo ./bin/phd status
ID Host PID Started Daemon Arguments
38 localhost 2282 Jun 18 2014, 7:52:56 AM PhabricatorRepositoryPullLocalDaemon
39 localhost 2289 Jun 18 2014, 7:52:57 AM PhabricatorGarbageCollectorDaemon
40 localhost 2294 Jun 18 2014, 7:52:57 AM PhabricatorTaskmasterDaemon
41 localhost 2314 Jun 18 2014, 7:52:58 AM PhabricatorTaskmasterDaemon
42 localhost 2319 Jun 18 2014, 7:52:59 AM PhabricatorTaskmasterDaemon
43 localhost 2328 Jun 18 2014, 7:53:00 AM PhabricatorTaskmasterDaemon
44 localhost 2354 Jun 18 2014, 7:53:08 AM PhabricatorRepositoryPullLocalDaemon X --not Y
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9607
2014-06-18 03:44:52 +02:00
|
|
|
'explicitArgv' => self::SERIALIZATION_JSON,
|
2013-07-23 21:11:34 +02:00
|
|
|
),
|
2014-09-18 20:15:29 +02:00
|
|
|
self::CONFIG_COLUMN_SCHEMA => array(
|
|
|
|
'daemon' => 'text255',
|
|
|
|
'host' => 'text255',
|
|
|
|
'pid' => 'uint32',
|
2014-12-23 17:11:44 +01:00
|
|
|
'runningAsUser' => 'text255?',
|
2014-09-18 20:15:29 +02:00
|
|
|
'status' => 'text8',
|
2015-02-23 20:26:38 +01:00
|
|
|
'daemonID' => 'text64',
|
2014-09-18 20:15:29 +02:00
|
|
|
),
|
2014-10-01 16:53:50 +02:00
|
|
|
self::CONFIG_KEY_SCHEMA => array(
|
|
|
|
'status' => array(
|
|
|
|
'columns' => array('status'),
|
|
|
|
),
|
|
|
|
'dateCreated' => array(
|
|
|
|
'columns' => array('dateCreated'),
|
|
|
|
),
|
2015-02-23 20:26:38 +01:00
|
|
|
'key_daemonID' => array(
|
|
|
|
'columns' => array('daemonID'),
|
|
|
|
'unique' => true,
|
|
|
|
),
|
2014-10-01 16:53:50 +02:00
|
|
|
),
|
2013-07-23 21:11:34 +02:00
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
2014-06-27 00:23:22 +02:00
|
|
|
public function getExplicitArgv() {
|
|
|
|
$argv = $this->explicitArgv;
|
|
|
|
if (!is_array($argv)) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
return $argv;
|
|
|
|
}
|
|
|
|
|
2013-07-23 21:11:34 +02:00
|
|
|
|
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
2013-10-14 23:35:47 +02:00
|
|
|
public function getPHID() {
|
|
|
|
return null;
|
|
|
|
}
|
2013-07-23 21:11:34 +02:00
|
|
|
|
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
|
|
|
return PhabricatorPolicies::POLICY_ADMIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|