|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace test\Vivait\TenantBundle\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
6
|
|
|
use Symfony\Component\Console\Command\Command; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
11
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
|
12
|
|
|
use Vivait\TenantBundle\Kernel\TenantKernel; |
|
13
|
|
|
use Vivait\TenantBundle\Model\Tenant; |
|
14
|
|
|
use Vivait\TenantBundle\Registry\TenantRegistry; |
|
15
|
|
|
|
|
16
|
|
|
class CrashCommand extends ContainerAwareCommand |
|
17
|
|
|
{ |
|
18
|
|
|
protected function configure() |
|
19
|
|
|
{ |
|
20
|
|
|
$this |
|
21
|
|
|
->setName('vivait:tenants:crash') |
|
22
|
|
|
->setDescription('Waits a specified number of seconds and then crashes - use only for debugging') |
|
23
|
|
|
->addArgument('tenant', InputArgument::REQUIRED, 'Tenant to crash for') |
|
24
|
|
|
->addArgument('time', InputArgument::OPTIONAL, 'Number of seconds to wait', 2) |
|
25
|
|
|
; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
29
|
|
|
{ |
|
30
|
|
|
$tenant = 'tenant_'. $input->getArgument('tenant'); |
|
31
|
|
|
/** @var Kernel $kernel */ |
|
32
|
|
|
$kernel = $this->getContainer()->get('kernel'); |
|
33
|
|
|
|
|
34
|
|
|
for ($i = 1; $i <= $input->getArgument('time'); $i++) { |
|
35
|
|
|
echo $i; |
|
36
|
|
|
sleep(1); |
|
37
|
|
|
|
|
38
|
|
|
if ($tenant == $kernel->getEnvironment()) { |
|
39
|
|
|
throw new \Exception('Crashed'); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|