mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-15 17:21:10 +01:00
Ping conduit from PHD and set daemon logfiles.
This commit is contained in:
parent
1d28d97307
commit
8f63873d57
2 changed files with 32 additions and 2 deletions
|
@ -42,6 +42,8 @@ switch (isset($argv[1]) ? $argv[1] : 'help') {
|
||||||
if (!$need_launch) {
|
if (!$need_launch) {
|
||||||
echo "There are no repositories with tracking enabled.\n";
|
echo "There are no repositories with tracking enabled.\n";
|
||||||
} else {
|
} else {
|
||||||
|
will_launch($control);
|
||||||
|
|
||||||
foreach ($need_launch as $repository) {
|
foreach ($need_launch as $repository) {
|
||||||
$name = $repository->getName();
|
$name = $repository->getName();
|
||||||
$callsign = $repository->getCallsign();
|
$callsign = $repository->getCallsign();
|
||||||
|
@ -63,6 +65,8 @@ switch (isset($argv[1]) ? $argv[1] : 'help') {
|
||||||
if (!$need_launch) {
|
if (!$need_launch) {
|
||||||
echo "There are no repositories with tracking enabled.\n";
|
echo "There are no repositories with tracking enabled.\n";
|
||||||
} else {
|
} else {
|
||||||
|
will_launch($control);
|
||||||
|
|
||||||
foreach ($need_launch as $repository) {
|
foreach ($need_launch as $repository) {
|
||||||
$name = $repository->getName();
|
$name = $repository->getName();
|
||||||
$callsign = $repository->getCallsign();
|
$callsign = $repository->getCallsign();
|
||||||
|
@ -159,6 +163,8 @@ switch (isset($argv[1]) ? $argv[1] : 'help') {
|
||||||
$daemon = reset($match);
|
$daemon = reset($match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
will_launch($control);
|
||||||
|
|
||||||
if ($is_debug) {
|
if ($is_debug) {
|
||||||
echo "Launching {$daemon} in debug mode (nondaemonized)...\n";
|
echo "Launching {$daemon} in debug mode (nondaemonized)...\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,3 +216,11 @@ function phd_load_tracked_repositories() {
|
||||||
|
|
||||||
return $repositories;
|
return $repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function will_launch($control) {
|
||||||
|
echo "Staging launch...\n";
|
||||||
|
$control->pingConduit();
|
||||||
|
$log_dir = $control->getControlDirectory('log').'/daemons.log';
|
||||||
|
echo "NOTE: Logs will appear in '{$log_dir}'.\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,19 @@ EOHELP
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function pingConduit() {
|
||||||
|
// It's fairly common to have issues here, e.g. because Phabricator isn't
|
||||||
|
// running, isn't accessible, you put the domain in your hostsfile but it
|
||||||
|
// isn't available on the production host, etc. If any of this doesn't work,
|
||||||
|
// conduit will throw.
|
||||||
|
|
||||||
|
// We do this here rather than in the daemon since there's an HTTPS + curl
|
||||||
|
// + fork issue of some kind that makes
|
||||||
|
$conduit = new ConduitClient(PhabricatorEnv::getURI('/api/'));
|
||||||
|
$conduit->setTimeout(5);
|
||||||
|
$conduit->callMethodSynchronous('conduit.ping', array());
|
||||||
|
}
|
||||||
|
|
||||||
public function launchDaemon($daemon, array $argv, $debug = false) {
|
public function launchDaemon($daemon, array $argv, $debug = false) {
|
||||||
$symbols = $this->loadAvailableDaemonClasses();
|
$symbols = $this->loadAvailableDaemonClasses();
|
||||||
$symbols = ipull($symbols, 'name', 'name');
|
$symbols = ipull($symbols, 'name', 'name');
|
||||||
|
@ -171,6 +184,7 @@ EOHELP
|
||||||
}
|
}
|
||||||
|
|
||||||
$pid_dir = $this->getControlDirectory('pid');
|
$pid_dir = $this->getControlDirectory('pid');
|
||||||
|
$log_dir = $this->getControlDirectory('log').'/daemons.log';
|
||||||
|
|
||||||
$libphutil_root = dirname(phutil_get_library_root('phutil'));
|
$libphutil_root = dirname(phutil_get_library_root('phutil'));
|
||||||
$launch_daemon = $libphutil_root.'/scripts/daemon/';
|
$launch_daemon = $libphutil_root.'/scripts/daemon/';
|
||||||
|
@ -205,12 +219,14 @@ EOHELP
|
||||||
implode(' ', $extra_libraries)." ".
|
implode(' ', $extra_libraries)." ".
|
||||||
"--conduit-uri=%s ".
|
"--conduit-uri=%s ".
|
||||||
"--phd=%s ".
|
"--phd=%s ".
|
||||||
|
"--log=%s ".
|
||||||
($debug ? '--trace ' : '--daemonize ').
|
($debug ? '--trace ' : '--daemonize ').
|
||||||
implode(' ', $argv),
|
implode(' ', $argv),
|
||||||
$daemon,
|
$daemon,
|
||||||
phutil_get_library_root('phabricator'),
|
phutil_get_library_root('phabricator'),
|
||||||
PhabricatorEnv::getURI('/api/'),
|
PhabricatorEnv::getURI('/api/'),
|
||||||
$pid_dir);
|
$pid_dir,
|
||||||
|
$log_dir);
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
// Don't terminate when the user sends ^C; it will be sent to the
|
// Don't terminate when the user sends ^C; it will be sent to the
|
||||||
|
@ -234,7 +250,7 @@ EOHELP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getControlDirectory($dir) {
|
public function getControlDirectory($dir) {
|
||||||
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir;
|
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir;
|
||||||
if (!Filesystem::pathExists($path)) {
|
if (!Filesystem::pathExists($path)) {
|
||||||
list($err) = exec_manual('mkdir -p %s', $path);
|
list($err) = exec_manual('mkdir -p %s', $path);
|
||||||
|
|
Loading…
Reference in a new issue