Differential D15711 Diff 37866 src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
| Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | protected function parseLaunchArguments(PhutilArgumentParser $args) { | ||||
| } | } | ||||
| try { | try { | ||||
| PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
| $data, | $data, | ||||
| array( | array( | ||||
| 'servers' => 'list<wild>', | 'servers' => 'list<wild>', | ||||
| 'logs' => 'optional list<wild>', | 'logs' => 'optional list<wild>', | ||||
| 'cluster' => 'optional list<wild>', | |||||
| 'pidfile' => 'string', | 'pidfile' => 'string', | ||||
| )); | )); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| 'Configuration file has improper configuration keys at top '. | 'Configuration file has improper configuration keys at top '. | ||||
| 'level. %s', | 'level. %s', | ||||
| $ex->getMessage())); | $ex->getMessage())); | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if (!$has_admin) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| 'Configuration file does not specify any administrative '. | 'Configuration file does not specify any administrative '. | ||||
| 'servers. This service will be unable to receive messages. '. | 'servers. This service will be unable to receive messages. '. | ||||
| 'You must specify at least one server with type "%s".', | 'You must specify at least one server with type "%s".', | ||||
| 'admin')); | 'admin')); | ||||
| } | } | ||||
| $logs = $data['logs']; | $logs = idx($data, 'logs', array()); | ||||
| foreach ($logs as $index => $log) { | foreach ($logs as $index => $log) { | ||||
| PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
| $log, | $log, | ||||
| array( | array( | ||||
| 'path' => 'string', | 'path' => 'string', | ||||
| )); | )); | ||||
| $path = $log['path']; | $path = $log['path']; | ||||
| Show All 9 Lines | foreach ($logs as $index => $log) { | ||||
| 'Failed to create directory "%s" for specified log file (with '. | 'Failed to create directory "%s" for specified log file (with '. | ||||
| 'index "%s"). You should manually create this directory or '. | 'index "%s"). You should manually create this directory or '. | ||||
| 'choose a different logfile location. %s', | 'choose a different logfile location. %s', | ||||
| $dir, | $dir, | ||||
| $ex->getMessage())); | $ex->getMessage())); | ||||
| } | } | ||||
| } | } | ||||
| $peer_map = array(); | |||||
| $cluster = idx($data, 'cluster', array()); | |||||
| foreach ($cluster as $index => $peer) { | |||||
| PhutilTypeSpec::checkMap( | |||||
| $peer, | |||||
| array( | |||||
| 'host' => 'string', | |||||
| 'port' => 'int', | |||||
| 'protocol' => 'string', | |||||
| )); | |||||
| $host = $peer['host']; | |||||
| $port = $peer['port']; | |||||
| $protocol = $peer['protocol']; | |||||
| switch ($protocol) { | |||||
| case 'http': | |||||
| case 'https': | |||||
| break; | |||||
| default: | |||||
| throw new PhutilArgumentUsageException( | |||||
| pht( | |||||
| 'Configuration file specifies cluster peer ("%s", at index '. | |||||
| '"%s") with an invalid protocol, "%s". Valid protocols are '. | |||||
| '"%s" or "%s".', | |||||
| $host, | |||||
| $index, | |||||
| $protocol, | |||||
| 'http', | |||||
| 'https')); | |||||
| } | |||||
| $peer_key = "{$host}:{$port}"; | |||||
| if (!isset($peer_map[$peer_key])) { | |||||
| $peer_map[$peer_key] = $index; | |||||
| } else { | |||||
| throw new PhutilArgumentUsageException( | |||||
| pht( | |||||
| 'Configuration file specifies cluster peer "%s" more than '. | |||||
| 'once (at indexes "%s" and "%s"). Each peer must have a '. | |||||
| 'unique host and port combination.', | |||||
| $peer_key, | |||||
| $peer_map[$peer_key], | |||||
| $index)); | |||||
| } | |||||
| } | |||||
| $this->configData = $data; | $this->configData = $data; | ||||
| $this->configPath = $full_path; | $this->configPath = $full_path; | ||||
| $pid_path = $this->getPIDPath(); | $pid_path = $this->getPIDPath(); | ||||
| try { | try { | ||||
| $dir = dirname($path); | $dir = dirname($path); | ||||
| if (!Filesystem::pathExists($dir)) { | if (!Filesystem::pathExists($dir)) { | ||||
| Filesystem::createDirectory($dir, 0755, true); | Filesystem::createDirectory($dir, 0755, true); | ||||
| ▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines | |||||