Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->instances->lock();
     $container = $this->getContainer();
     $mysql_type = $container->getParameter('mysql_type');
     if ($mysql_type == "") {
         $this->doCommand($output, OutputInterface::VERBOSITY_NORMAL, 'config', array());
         $this->getApplication()->loadContainer();
         $this->instances = $this->getContainer()->get('instances');
     }
     $instance = $this->instances->find(Instance::makeId($input->getOption('root'), $input->getOption('name')));
     if ($instance === NULL) {
         $instance = new Instance();
         $instance->setRoot($input->getOption('root'));
         $instance->setName($input->getOption('name'));
     } elseif (!$input->getOption('force')) {
         throw new \Exception("Cannot create instance. Use -f to overwrite existing instance.");
     }
     if ($input->getOption('url')) {
         $instance->setUrl($input->getOption('url'));
     }
     $this->instances->create($instance, !$input->getOption('skip-url'), !$input->getOption('skip-db'), $input->getOption('perm'));
     $this->instances->save();
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_QUIET) {
         $this->export($instance->getRoot(), $instance->getName(), $input->getOption('prefix'), $input->getOption('output-file'), $output);
     }
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->instances->lock();
     $instance = $this->instances->find(Instance::makeId($input->getOption('root'), $input->getOption('name')));
     if (!$instance) {
         return;
     }
     $this->instances->remove($instance->getId());
     $this->instances->save();
 }
Ejemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->instances->lock();
     $count = 0;
     foreach ($this->instances->findAll() as $instance) {
         if ($input->getOption('force') || !file_exists($instance->getRoot())) {
             $output->writeln("Destroy (root={$instance->getRoot()}, name={$instance->getName()}, dsn={$instance->getDsn()})");
             $this->instances->remove($instance->getId());
             $count++;
         } else {
             $output->writeln("Skip (root={$instance->getRoot()}, name={$instance->getName()}, dsn={$instance->getDsn()})");
         }
     }
     $output->writeln("Destroyed {$count} instance(s)");
     $this->instances->save();
 }
Ejemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->instances->lock();
     // Display help text
     //$output->write($this->templateEngine->render('testing.php', array(
     //  'apache_dir' => $this->getContainer()->getParameter('apache_dir'),
     //  'nginx_dir' => $this->getContainer()->getParameter('nginx_dir'),
     //)));
     // Setup test instance
     $output->writeln("<info>Create test application</info>");
     list($root, $dataDir) = $this->createCanaryFiles($output);
     $this->doCommand($output, OutputInterface::VERBOSITY_NORMAL, 'create', array('--root' => $root, '--force' => 1, '--url' => 'http://localhost:7979'));
     $output->writeln("");
     // Connect to test instance
     $output->writeln("<info>Connect to test application</info>");
     $output->writeln("<comment>Expect response: \"{$this->expectedResponse}\"</comment>");
     $this->instances->load();
     // force reload
     $instance = $this->instances->find(Instance::makeId($root, ''));
     $response = $this->doPost($instance->getUrl() . '/index.php', array('dsn' => $instance->getDsn()));
     if ($response == $this->expectedResponse) {
         $output->writeln("<info>Received expected response</info>");
         // Tear down test instance
         // Skip teardown; this allows us to preserve the port-number
         // across multiple executions.
         //$output->writeln("<info>Cleanup test application</info>");
         //$this->doCommand($output, OutputInterface::VERBOSITY_NORMAL, 'destroy', array(
         //  '--root' => $root,
         //));
     } else {
         $output->writeln("<error>Received incorrect response: \"{$response}\"</error>");
         $output->writeln("<comment>Tip: Try running \"amp config\" and/or restarting the webserver.</comment>");
     }
     if (!rmdir($dataDir)) {
         $output->writeln("<error>Failed to clean up data directory: {$dataDir}</error>");
     }
 }