Skip to content

Commit

Permalink
Update docker_queue.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangmy21 authored May 9, 2024
1 parent 41a3941 commit db04566
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/helpers/docker_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ const docker_cron = async () => {
console.debug("client_memory_limit (GB): " + client_memory_limit);

// try creating containers, if failed, retry next time.
const new_containers: Docker.Container[] = [];
try {
const new_containers: Docker.Container[] = [];

const port = await get_port();
if (port === -1) {
console.log("no port available")
Expand Down Expand Up @@ -359,7 +358,17 @@ const docker_cron = async () => {

} catch (err) {
console.error("An error occurred in creating containers:", err);
await hasura.update_room_status_and_port(queue_front.room_id, "Failed", null);
new_containers.forEach(async (container) => {
try {
console.log("Removing container: " + container.id);
container.remove({
force: true
});
} catch (err) {
console.error("An error occurred in removing containers:", err);
}
});
await hasura.update_room_status_and_port(queue_front.room_id, "Crashed", null);
return;
}

Expand Down

0 comments on commit db04566

Please sign in to comment.