예제 #1
0
 /**
  * @return Workspace
  * @throws \Exception
  */
 public function fetch()
 {
     try {
         $destination = $this->getTempDirectory();
         $this->getStrategy()->extract($this->archive, $destination);
     } catch (\Exception $ex) {
         throw $ex;
     }
     $directory = new Directory($destination->getPathname());
     $directory->setEventManager($this->getEventManager());
     $directory->setFilters($this->iteratorFilters);
     return $directory->fetch();
 }
예제 #2
0
 public function install(EventInterface $event)
 {
     $build = $event->getParam('build');
     /** @var Application $application */
     $application = $event->getTarget();
     $this->setApplication($application);
     $this->setBuild($build);
     $message = $application->getName() . ' deployment launched from ' . $event->getParam('source') . ' for build ' . $build;
     $this->getLogger()->debug($message);
     /** @var Continuousphp $provider */
     $provider = $application->getProvider();
     $origin = $provider->getSource($build);
     $origin->setFilename($build . '.tar.gz');
     $origin->getEventManager()->attach(DeployEvent::EVENT_FETCH_PRE, function (DeployEvent $event) {
         $this->getLogger()->info('Downloading package...');
     });
     $mask = umask(0);
     $this->getPackageFileSystem()->createDir($application->getName());
     $resourcePath = $this->getPackageStoragePath() . DIRECTORY_SEPARATOR . $application->getName() . DIRECTORY_SEPARATOR . $build . '.tar.gz';
     $resource = new Archive($resourcePath);
     $resource->getEventManager()->attach(DeployEvent::EVENT_FETCH_PRE, function () {
         $this->getLogger()->info('Extracting package...');
     });
     $destination = new Directory($application->getPath() . DIRECTORY_SEPARATOR . $build);
     $destination->getEventManager()->attach(DeployEvent::EVENT_RECEIVE_POST, function () use($application) {
         $application->getEventManager()->trigger($application::EVENT_ACTIVATE);
     });
     $agent = new Agent();
     $agent->setSource($origin)->setResource($resource)->setDestination($destination);
     $agent->deploy();
     umask($mask);
 }