Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14422102
D11855.id28561.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D11855.id28561.diff
View Options
diff --git a/scripts/daemon/launch_daemon.php b/scripts/daemon/launch_daemon.php
--- a/scripts/daemon/launch_daemon.php
+++ b/scripts/daemon/launch_daemon.php
@@ -8,20 +8,11 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-$flags = array();
+$overseer = new PhutilDaemonOverseer($argv);
$bootloader = PhutilBootloader::getInstance();
foreach ($bootloader->getAllLibraries() as $library) {
- if ($library == 'phutil') {
- // No need to load libphutil, it's necessarily loaded implicitly by the
- // daemon itself.
- continue;
- }
- $flags[] = '--load-phutil-library='.phutil_get_library_root($library);
+ $overseer->addLibrary(phutil_get_library_root($library));
}
-// Add more flags.
-array_splice($argv, 2, 0, $flags);
-
-$overseer = new PhutilDaemonOverseer($argv);
$overseer->run();
diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
--- a/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
+++ b/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
@@ -165,10 +165,6 @@
}
}
- foreach ($argv as $key => $arg) {
- $argv[$key] = escapeshellarg($arg);
- }
-
$flags = array();
if ($debug || PhabricatorEnv::getEnvConfig('phd.trace')) {
$flags[] = '--trace';
@@ -178,13 +174,14 @@
$flags[] = '--verbose';
}
+ $config = array();
+
if (!$debug) {
- $flags[] = '--daemonize';
+ $config['daemonize'] = true;
}
if (!$debug) {
- $log_file = $this->getLogDirectory().'/daemons.log';
- $flags[] = csprintf('--log=%s', $log_file);
+ $config['log'] = $this->getLogDirectory().'/daemons.log';
}
$pid_dir = $this->getPIDDirectory();
@@ -194,13 +191,16 @@
Filesystem::assertIsDirectory($pid_dir);
Filesystem::assertWritable($pid_dir);
- $flags[] = csprintf('--phd=%s', $pid_dir);
+ $config['piddir'] = $pid_dir;
- $command = csprintf(
- './phd-daemon %s %C %C',
- $daemon,
- implode(' ', $flags),
- implode(' ', $argv));
+ $config['daemons'] = array(
+ array(
+ 'class' => $daemon,
+ 'argv' => $argv,
+ ),
+ );
+
+ $command = csprintf('./phd-daemon %Ls', $flags);
$phabricator_root = dirname(phutil_get_library_root('phabricator'));
$daemon_script_dir = $phabricator_root.'/scripts/daemon/';
@@ -214,12 +214,20 @@
echo "\n phabricator/scripts/daemon/ \$ {$command}\n\n";
- phutil_passthru('(cd %s && exec %C)', $daemon_script_dir, $command);
+ $tempfile = new TempFile('daemon.config');
+ Filesystem::writeFile($tempfile, json_encode($config));
+
+ phutil_passthru(
+ '(cd %s && exec %C < %s)',
+ $daemon_script_dir,
+ $command,
+ $tempfile);
} else {
try {
$this->executeDaemonLaunchCommand(
$command,
$daemon_script_dir,
+ $config,
$this->runDaemonsAsUser);
} catch (Exception $e) {
// Retry without sudo
@@ -227,7 +235,8 @@
"sudo command failed. Starting daemon as current user\n"));
$this->executeDaemonLaunchCommand(
$command,
- $daemon_script_dir);
+ $daemon_script_dir,
+ $config);
}
}
}
@@ -235,6 +244,7 @@
private function executeDaemonLaunchCommand(
$command,
$daemon_script_dir,
+ array $config,
$run_as_user = null) {
$is_sudo = false;
@@ -250,6 +260,7 @@
$future = new ExecFuture('exec %C', $command);
// Play games to keep 'ps' looking reasonable.
$future->setCWD($daemon_script_dir);
+ $future->write(json_encode($config));
list($stdout, $stderr) = $future->resolvex();
if ($is_sudo) {
diff --git a/src/infrastructure/daemon/control/PhabricatorDaemonReference.php b/src/infrastructure/daemon/control/PhabricatorDaemonReference.php
--- a/src/infrastructure/daemon/control/PhabricatorDaemonReference.php
+++ b/src/infrastructure/daemon/control/PhabricatorDaemonReference.php
@@ -27,8 +27,23 @@
public static function newFromDictionary(array $dict) {
$ref = new PhabricatorDaemonReference();
- $ref->name = idx($dict, 'name', 'Unknown');
- $ref->argv = idx($dict, 'argv', array());
+ // TODO: This is a little rough during the transition from one-to-one
+ // overseers to one-to-many.
+ $config = idx($dict, 'config', array());
+
+ $daemon_list = null;
+ if ($config) {
+ $daemon_list = idx($config, 'daemons');
+ }
+
+ if ($daemon_list) {
+ $ref->name = pht('Overseer Daemon Group');
+ $ref->argv = array();
+ } else {
+ $ref->name = idx($dict, 'name', 'Unknown');
+ $ref->argv = idx($dict, 'argv', array());
+ }
+
$ref->pid = idx($dict, 'pid');
$ref->start = idx($dict, 'start');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 7:23 AM (11 h, 30 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6927526
Default Alt Text
D11855.id28561.diff (4 KB)
Attached To
Mode
D11855: Pass overseer configuration over stdin
Attached
Detach File
Event Timeline
Log In to Comment