Deployer\Cluster\Node::initialize PHP Method

initialize() public method

initialize the node
public initialize ( ) : Deployer\Cluster\NodeInterface
return Deployer\Cluster\NodeInterface
    public function initialize()
    {
        $env = new Environment();
        $config = new Configuration($this->name, $this->host, $this->port);
        $this->server = new PhpSecLib($config);
        if (\Deployer\has('ssh_type') && \Deployer\get('ssh_type') === 'ext-ssh2') {
            $this->server = new SshExtension($config);
        }
        $this->builder = new Builder($config, $env);
        $this->deployer->servers->set($this->name, $this->server);
        $this->deployer->environments->set($this->name, $env);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * @param Deployer $deployer
  * @param string $name
  * @param array $nodes
  * @param int $port
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(Deployer $deployer, $name, $nodes, $port)
 {
     if (count($nodes) < 1) {
         throw new \InvalidArgumentException('You must define at least one node to deploy');
     }
     $this->name = $name;
     $this->port = $port;
     foreach ($nodes as $key => $host) {
         $nName = $name . '_' . $key;
         $node = new Node();
         $node->setDeployer($deployer)->setName($nName)->setHost($host)->setPort($port);
         $node->initialize();
         $this->nodes[] = $node;
     }
     $this->clusterBuilder = new ClusterBuilder($this->nodes);
 }