mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-14 08:42:38 -04:00
Container ownership labels now use UUIDs: coolify.applicationUuid, coolify.serviceUuid, coolify.service.subUuid and coolify.databaseUuid. Numeric ids differ between Coolify instances, so after a server transfer the target could not find existing containers: redeploys left the old container running and service statuses were wrong. Containers are matched by UUID label first, then by the compose project (Swarm: stack namespace), which is the resource UUID since July 2024, and last by the older numeric id label. Existing containers keep working without a redeploy and get the UUID labels on the next deploy or restart.
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Actions\Application;
|
|
|
|
use App\Models\Application;
|
|
use App\Models\Server;
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
class StopApplicationOneServer
|
|
{
|
|
use AsAction;
|
|
|
|
public function handle(Application $application, Server $server)
|
|
{
|
|
if ($application->destination->server->isSwarm()) {
|
|
return;
|
|
}
|
|
if (! $server->isFunctional()) {
|
|
return 'Server is not functional';
|
|
}
|
|
try {
|
|
$containers = getCurrentApplicationContainerStatus($server, $application, 0);
|
|
$timeout = $application->settings->stopGracePeriodSeconds();
|
|
|
|
if ($containers->count() > 0) {
|
|
foreach ($containers as $container) {
|
|
$containerName = data_get($container, 'Names');
|
|
if ($containerName) {
|
|
instant_remote_process(
|
|
[
|
|
dockerStopCommand($timeout, escapeshellarg($containerName), $server),
|
|
dockerRemoveCommand($containerName),
|
|
],
|
|
$server
|
|
);
|
|
}
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
}
|