Example #1
0
 /**
  * @param \Peanut\Console\Application $app
  * @param array                       $config
  */
 public function exec(\Peanut\Console\Application $app, array $config)
 {
     $name = $app->getArgument('container name');
     $force = $app->getOption('force');
     $this->initMachine();
     $this->dockerRm($name, $force);
 }
Example #2
0
 /**
  * @param \Peanut\Console\Application $app
  * @param array                       $config
  */
 public function exec(\Peanut\Console\Application $app, array $config)
 {
     $isFollow = $app->getOption('follow');
     $name = $app->getArgument('container name');
     $this->initMachine();
     $this->dockerLog($name, $isFollow);
 }
Example #3
0
 /**
  * @param \Peanut\Console\Application $app
  * @param array                       $config
  */
 public function exec(\Peanut\Console\Application $app, array $config)
 {
     $isAll = $app->getOption('all');
     $config = $this->getConfig();
     $this->initMachine($config);
     echo PHP_EOL;
     $this->dockerLs($isAll);
 }
Example #4
0
 /**
  * @param \Peanut\Console\Application $app
  * @param array                       $config
  */
 public function exec(\Peanut\Console\Application $app, array $config)
 {
     $this->process('sudo -v', ['print' => false]);
     $mode = $app->getOption('attach') ? 'attach' : 'detach';
     $ispull = $app->getOption('pull') ? true : false;
     if ('attach' == $mode) {
         if (false === function_exists('pcntl_fork')) {
             $mode = 'detach';
             echo \Peanut\Console\Color::text('attach mode is not support, start detach mode', 'red', '') . PHP_EOL;
         }
         $this->loop = \React\EventLoop\Factory::create();
         try {
             $this->run();
             $pcntl = new \MKraemer\ReactPCNTL\PCNTL($this->loop);
             $pcntl->on(SIGTERM, function () {
                 // kill
                 echo 'SIGTERM' . PHP_EOL;
                 exit;
             });
             $pcntl->on(SIGHUP, function () {
                 // logout
                 echo 'SIGHUP' . PHP_EOL;
                 exit;
             });
             $pcntl->on(SIGINT, function () {
                 // ctrl+c
                 echo 'Terminated by console' . PHP_EOL;
                 posix_kill(posix_getpid(), SIGUSR1);
                 echo $this->process('docker rm -f $(docker ps -q)');
                 exit;
             });
             echo 'Started as PID ' . getmypid() . PHP_EOL;
             $this->loop->run();
         } catch (\Exception $e) {
             throw new \Peanut\Console\Exception($e);
         }
     } else {
         $this->run($mode, $ispull);
         echo PHP_EOL;
         $this->dockerLs();
     }
 }
Example #5
0
 /**
  * @param  \Peanut\Console\Application $app
  * @return mixed
  */
 public function execute(\Peanut\Console\Application $app)
 {
     $this->config = $this->getConfig();
     $this->verbose = $app->getOption('verbose');
     return $this->exec($app, $this->config);
 }