refactor(api): modify service sub container retrieval filter to use coolify.name
This commit is contained in:
parent
28e20473da
commit
c239b8bbba
2 changed files with 4 additions and 10 deletions
|
|
@ -536,14 +536,8 @@ public function logs_by_uuid(Request $request)
|
|||
return response()->json(['message' => 'Service not found.'], 404);
|
||||
}
|
||||
|
||||
$containers = getCurrentServiceSubContainerStatus($service->destination->server, $service->id, $subServiceName);
|
||||
|
||||
if ($containers->count() == 0) {
|
||||
return response()->json([
|
||||
'message' => 'Service is not running.',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$name = "{$subServiceName}-{$service->uuid}";
|
||||
$containers = getCurrentServiceSubContainerStatus($service->destination->server, $service->id, $name);
|
||||
$container = $containers->first();
|
||||
|
||||
if (! $container) {
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ function getCurrentDatabaseContainerStatus(Server $server, int $id): Collection
|
|||
return $containers;
|
||||
}
|
||||
|
||||
function getCurrentServiceSubContainerStatus(Server $server, int $id, string $subName): Collection
|
||||
function getCurrentServiceSubContainerStatus(Server $server, int $id, string $name): Collection
|
||||
{
|
||||
$containers = collect([]);
|
||||
if (! $server->isSwarm()) {
|
||||
$containers = instant_remote_process(["docker ps -a --filter='label=coolify.serviceId={$id}' --filter='label=coolify.service.subName={$subName}' --format '{{json .}}' "], $server);
|
||||
$containers = instant_remote_process(["docker ps -a --filter='label=coolify.serviceId={$id}' --filter='label=coolify.name={$name}' --format '{{json .}}' "], $server);
|
||||
$containers = format_docker_command_output_to_json($containers);
|
||||
|
||||
return $containers->filter();
|
||||
|
|
|
|||
Loading…
Reference in a new issue