1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 16:00:59 +01:00

Ping conduit from PHD and set daemon logfiles.

This commit is contained in:
epriestley 2011-06-13 18:39:23 -07:00
parent 1d28d97307
commit 8f63873d57
2 changed files with 32 additions and 2 deletions

View file

@ -42,6 +42,8 @@ switch (isset($argv[1]) ? $argv[1] : 'help') {
if (!$need_launch) {
echo "There are no repositories with tracking enabled.\n";
} else {
will_launch($control);
foreach ($need_launch as $repository) {
$name = $repository->getName();
$callsign = $repository->getCallsign();
@ -63,6 +65,8 @@ switch (isset($argv[1]) ? $argv[1] : 'help') {
if (!$need_launch) {
echo "There are no repositories with tracking enabled.\n";
} else {
will_launch($control);
foreach ($need_launch as $repository) {
$name = $repository->getName();
$callsign = $repository->getCallsign();
@ -159,6 +163,8 @@ switch (isset($argv[1]) ? $argv[1] : 'help') {
$daemon = reset($match);
}
will_launch($control);
if ($is_debug) {
echo "Launching {$daemon} in debug mode (nondaemonized)...\n";
} else {
@ -210,3 +216,11 @@ function phd_load_tracked_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";
}

View file

@ -163,6 +163,19 @@ EOHELP
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) {
$symbols = $this->loadAvailableDaemonClasses();
$symbols = ipull($symbols, 'name', 'name');
@ -171,6 +184,7 @@ EOHELP
}
$pid_dir = $this->getControlDirectory('pid');
$log_dir = $this->getControlDirectory('log').'/daemons.log';
$libphutil_root = dirname(phutil_get_library_root('phutil'));
$launch_daemon = $libphutil_root.'/scripts/daemon/';
@ -205,12 +219,14 @@ EOHELP
implode(' ', $extra_libraries)." ".
"--conduit-uri=%s ".
"--phd=%s ".
"--log=%s ".
($debug ? '--trace ' : '--daemonize ').
implode(' ', $argv),
$daemon,
phutil_get_library_root('phabricator'),
PhabricatorEnv::getURI('/api/'),
$pid_dir);
$pid_dir,
$log_dir);
if ($debug) {
// Don't terminate when the user sends ^C; it will be sent to the
@ -234,7 +250,7 @@ EOHELP
return;
}
protected function getControlDirectory($dir) {
public function getControlDirectory($dir) {
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory').'/'.$dir;
if (!Filesystem::pathExists($path)) {
list($err) = exec_manual('mkdir -p %s', $path);