Skip to content

Commit fdb0cd1

Browse files
committed
Remove messenger
1 parent cacd51f commit fdb0cd1

7 files changed

Lines changed: 138 additions & 183 deletions

File tree

src/Command/RunCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function execute(Input $input, Output $output): int
8989
try {
9090
$task->run(new Context($host));
9191
} catch (\Throwable $exception) {
92-
$this->deployer->messenger->renderException($exception, $host);
92+
$this->deployer->logger->renderException($exception, $host);
9393
}
9494
}
9595

src/Deployer.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
2222
use Deployer\Component\PharUpdate\Console\Command as PharUpdateCommand;
2323
use Deployer\Component\PharUpdate\Console\Helper as PharUpdateHelper;
2424
use Deployer\Component\Pimple\Container;
25-
use Deployer\Logger\Logger;
26-
use Deployer\ProcessRunner\ProcessRunner;
27-
use Deployer\Ssh\SshClient;
2825
use Deployer\Executor\Master;
29-
use Deployer\Executor\Messenger;
3026
use Deployer\Host\Host;
3127
use Deployer\Host\HostCollection;
3228
use Deployer\Host\Localhost;
3329
use Deployer\Importer\Importer;
3430
use Deployer\Logger\Handler\FileHandler;
3531
use Deployer\Logger\Handler\NullHandler;
32+
use Deployer\Logger\Logger;
33+
use Deployer\ProcessRunner\ProcessRunner;
3634
use Deployer\Selector\Selector;
35+
use Deployer\Ssh\SshClient;
3736
use Deployer\Task\ScriptManager;
3837
use Deployer\Task\TaskCollection;
3938
use Deployer\Utility\Httpie;
@@ -61,7 +60,6 @@
6160
* @property Task\ScriptManager $scriptManager
6261
* @property Selector $selector
6362
* @property Master $master
64-
* @property Messenger $messenger
6563
* @property Logger $logger
6664
* @property Collection $fail
6765
* @property InputDefinition $inputDefinition
@@ -127,7 +125,7 @@ public function __construct(Application $console)
127125
: new NullHandler();
128126
};
129127
$this['logger'] = function ($c) {
130-
return new Logger($c['output'], $this['logHandler']);
128+
return new Logger($c['input'], $c['output'], $this['logHandler']);
131129
};
132130
$this['sshClient'] = function ($c) {
133131
return new SshClient($c['output'], $c['logger']);
@@ -153,15 +151,12 @@ public function __construct(Application $console)
153151
$this['fail'] = function () {
154152
return new Collection();
155153
};
156-
$this['messenger'] = function ($c) {
157-
return new Messenger($c['input'], $c['output']);
158-
};
159154
$this['master'] = function ($c) {
160155
return new Master(
161156
$c['hosts'],
162157
$c['input'],
163158
$c['output'],
164-
$c['messenger'],
159+
$c['logger'],
165160
);
166161
};
167162
$this['importer'] = function () {

src/Executor/Master.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Deployer\Deployer;
1414
use Deployer\Host\Host;
1515
use Deployer\Host\HostCollection;
16+
use Deployer\Logger\Logger;
1617
use Deployer\Selector\Selector;
1718
use Deployer\Ssh\IOArguments;
1819
use Deployer\Task\Context;
@@ -35,19 +36,19 @@ class Master
3536
private HostCollection $hosts;
3637
private InputInterface $input;
3738
private OutputInterface $output;
38-
private Messenger $messenger;
39+
private Logger $logger;
3940
private string|false $phpBin;
4041

4142
public function __construct(
4243
HostCollection $hosts,
4344
InputInterface $input,
4445
OutputInterface $output,
45-
Messenger $messenger,
46+
Logger $logger,
4647
) {
4748
$this->hosts = $hosts;
4849
$this->input = $input;
4950
$this->output = $output;
50-
$this->messenger = $messenger;
51+
$this->logger = $logger;
5152
$this->phpBin = (new PhpExecutableFinder())->find();
5253
}
5354

@@ -61,7 +62,7 @@ public function run(array $tasks, array $hosts, ?Planner $plan = null): int
6162

6263
foreach ($tasks as $task) {
6364
if (!$plan) {
64-
$this->messenger->startTask($task);
65+
$this->logger->startTask($task);
6566
}
6667

6768
$plannedHosts = $hosts;
@@ -134,7 +135,7 @@ public function run(array $tasks, array $hosts, ?Planner $plan = null): int
134135
}
135136

136137
if (!$plan) {
137-
$this->messenger->endTask($task);
138+
$this->logger->endTask($task);
138139
}
139140
}
140141

@@ -156,7 +157,7 @@ private function runTask(Task $task, array $hosts): int
156157
$worker = new Worker(Deployer::get());
157158
$exitCode = $worker->execute($task, $host);
158159
if ($exitCode !== 0) {
159-
$this->messenger->endTask($task, true);
160+
$this->logger->endTask($task);
160161
return $exitCode;
161162
}
162163
}
@@ -235,7 +236,7 @@ private function runTask(Task $task, array $hosts): int
235236
$this->gatherOutput($processes, $echoCallback);
236237

237238
if ($this->cumulativeExitCode($processes) !== 0) {
238-
$this->messenger->endTask($task, true);
239+
$this->logger->endTask($task);
239240
}
240241

241242
return $this->cumulativeExitCode($processes);

src/Executor/Messenger.php

Lines changed: 0 additions & 157 deletions
This file was deleted.

src/Executor/Worker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function execute(Task $task, Host $host): int
3737
$task->run($context);
3838

3939
if ($task->getName() !== 'connect') {
40-
$this->deployer->messenger->endOnHost($host);
40+
$this->deployer->logger->endOnHost($host);
4141
}
4242
return 0;
4343
} catch (Throwable $e) {
44-
$this->deployer->messenger->renderException($e, $host);
44+
$this->deployer->logger->renderException($e, $host);
4545
if ($e instanceof GracefulShutdownException) {
4646
return GracefulShutdownException::EXIT_CODE;
4747
}

0 commit comments

Comments
 (0)