1 | <?php |
||
8 | class SupervisorConfigurationGenerator |
||
9 | { |
||
10 | private |
||
11 | $overwrite, |
||
12 | $filesystem, |
||
13 | $commandGenerator; |
||
14 | |||
15 | 5 | public function __construct(Filesystem $filesystem, CommandGenerator $commandGenerator) |
|
21 | |||
22 | 5 | public function generate(array $workers, $autostart, $autorestart, $appId, $destination, OutputInterface $output) |
|
23 | { |
||
24 | 5 | foreach($workers as $worker => $data) |
|
25 | { |
||
26 | 5 | $this->generateSupervisorConfigurationFile($worker, $autostart, $autorestart, $appId, $destination, $output); |
|
27 | } |
||
28 | 5 | } |
|
29 | |||
30 | 5 | private function generateSupervisorConfigurationFile($worker, $autostart, $autorestart, $appId, $destination, OutputInterface $output) |
|
31 | { |
||
32 | 5 | $configuration = $this->generateSupervisorConfiguration($worker, $autostart, $autorestart, $appId); |
|
33 | 5 | $filename = $this->buildFilename($appId, $worker); |
|
34 | |||
35 | 5 | $this->filesystem->write($filename, $configuration, $this->overwrite); |
|
36 | |||
37 | 5 | $message = sprintf('%s', $destination . $filename); |
|
38 | 5 | if($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) |
|
39 | { |
||
40 | $message = sprintf("<comment>%s%s</comment>\n%s\n", $destination, $filename, $configuration); |
||
41 | } |
||
42 | |||
43 | 5 | $output->writeln($message); |
|
44 | 5 | } |
|
45 | |||
46 | 5 | private function buildFilename($appId, $workerName) |
|
50 | |||
51 | 5 | private function generateSupervisorConfiguration($worker, $autostart, $autorestart, $appId) |
|
67 | |||
68 | 5 | private function booleanToString($value) |
|
72 | } |
||
73 |