Deployer\Bootstrap\BootstrapByConfigFile::initServers PHP Method

initServers() public method

public initServers ( ) : BootstrapByConfigFile
return BootstrapByConfigFile
    public function initServers()
    {
        foreach ((array) $this->serverConfig as $name => $config) {
            try {
                if (!is_array($config)) {
                    throw new \RuntimeException();
                }
                $da = new Collection($config);
                if ($da->has('local')) {
                    $builder = \Deployer\localServer($name);
                } else {
                    $builder = $da->has('port') ? $this->serverBuilders[] = \Deployer\server($name, $da['host'], $da['port']) : ($this->serverBuilders[] = \Deployer\server($name, $da['host']));
                }
                unset($da['local']);
                unset($da['host']);
                unset($da['port']);
                $this->executeBuilderMethods($da, $builder);
            } catch (\RuntimeException $e) {
                throw new \RuntimeException("Error processing servers: " . $name);
            }
        }
        return $this;
    }

Usage Example

Beispiel #1
0
/**
 * Load server list file.
 * @param string $file
 */
function serverList($file)
{
    $bootstrap = new Bootstrap\BootstrapByConfigFile();
    $bootstrap->setConfig($file);
    $bootstrap->parseConfig();
    $bootstrap->initServers();
    $bootstrap->initClusters();
}