Skip to content

Commit

Permalink
master Delete:470 execute proxy command only if instance is up
Browse files Browse the repository at this point in the history
  • Loading branch information
daniwe4 committed Oct 10, 2024
1 parent c882210 commit 768e5f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/Commands/Instances/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ protected function deleteInstance(
$this->docker->removeContainer($instance . "_" . $suffix);

$this->docker->executeCommand(self::SALT_MAIN, "doil_saltmain", "salt-key", "-d", "$instance.$suffix", "-y", "-q");
$this->docker->executeDockerCommand(
"doil_proxy",
"rm -f /etc/nginx/conf.d/sites/$instance.conf && /root/generate_index_html.sh"
);
if ($this->docker->isInstanceUp($path)) {
$this->docker->executeDockerCommand(
"doil_proxy",
"rm -f /etc/nginx/conf.d/sites/$instance.conf && /root/generate_index_html.sh"
);
}

if ($this->docker->hasVolume($instance)) {
$this->docker->removeVolume($instance);
Expand Down
6 changes: 6 additions & 0 deletions app/tests/Commands/Instances/DeleteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public function test_execute() : void
["/usr/local/lib/doil/server/mail/", "doil_mail", "/bin/bash", "-c", "/root/delete-postbox-configuration.sh $instance &>/dev/null"]
)
;
$docker
->expects($this->once())
->method("isInstanceUp")
->with("/usr/local/share/doil/instances/master")
->willReturn(true)
;
$docker
->expects($this->once())
->method("executeDockerCommand")
Expand Down

0 comments on commit 768e5f7

Please sign in to comment.