/**
  * Register Tasks with Rocketeer
  *
  * @param TasksQueue $queue
  *
  * @return void
  */
 public function onQueue(TasksHandler $handler)
 {
     // The following doesn't work, therefore the uncommented code
     // $handler->add('Tnarik\RocketeerDatabase\InitializeDatabase');
     $tasks = ['Tnarik\\RocketeerDatabase\\InitializeDatabase', 'Tnarik\\RocketeerDatabase\\CreateDatabase'];
     foreach ($tasks as $task) {
         $taskInstance = $handler->buildTaskFromClass($task);
         $slug = $taskInstance->getSlug();
         $handle = 'rocketeer.tasks.' . $slug;
         $this->app->bind($handle, function () use($taskInstance) {
             return $taskInstance;
         });
         $command = trim("deploy." . $slug, ".");
         $this->app->singleton($command, function () use($taskInstance, $slug) {
             return new \Rocketeer\Commands\BaseTaskCommand($taskInstance, $slug);
         });
         $this->app['rocketeer.console']->add($this->app[$command]);
     }
     $handler->after('deploy', function ($task) {
         if ($task->command->option("migrate") && $task->command->option("seed")) {
             $task->command->info("Migrations and seeds ctivated: database will be initialized");
             $this->initialize();
         } else {
             $task->command->info("Migrations and seeds deactivated");
         }
     });
     $handler->addTaskListeners('deploy', 'runComposer', function ($task) {
         if ($task->command->option("migrate")) {
             $task->command->info("Migrations activated: database will be created");
             $this->create();
         } else {
             $task->command->info("Migrations deactivated");
         }
     });
 }
Ejemplo n.º 2
0
 /**
  * Register Tasks with Rocketeer
  *
  * @param TasksHandler $queue
  *
  * @return void
  */
 public function onQueue(TasksHandler $queue)
 {
     $me = $this;
     $queue->before('deploy', function ($task) use($me) {
         $me->prepareThenSend($task, 'before_deploy');
     }, -10);
     $queue->after('deploy', function ($task) use($me) {
         $me->prepareThenSend($task, 'after_deploy');
     }, -10);
 }
 /**
  * Register Tasks with Rocketeer
  *
  * @param TasksQueue $queue
  *
  * @return void
  */
 public function onQueue(TasksHandler $handler)
 {
     $handler->addTaskListeners('deploy', 'runComposer', function ($task) {
         $task->command->info("Configuring remote environment based on the connection name");
         $connection = $task->rocketeer->getConnection();
         $currentReleasePath = $task->releasesManager->getCurrentReleasePath();
         $environment_file = "bootstrap" . DIRECTORY_SEPARATOR . "environment.php";
         $task->remote->putString($currentReleasePath . DIRECTORY_SEPARATOR . $environment_file, "<?php\n return '{$connection}';");
         $task->command->info("Created {$environment_file} for environment: {$connection}");
     });
     $handler->addTaskListeners('deploy', 'runComposer', function ($task) {
         $task->command->info("Copying environment settings to remote based on the connection name");
         $connection = $task->rocketeer->getConnection();
         $currentReleasePath = $task->releasesManager->getCurrentReleasePath();
         if (file_exists(".env.{$connection}.php")) {
             $task->remote->put(".env.{$connection}.php", $currentReleasePath . DIRECTORY_SEPARATOR . ".env.{$connection}.php");
             $task->command->info("Copied .env.{$connection}.php");
         } else {
             $task->command->error("Couldn't find .env.{$connection}.php");
         }
     });
 }