@noosphere/agent-core 0.1.0-alpha.8 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -456,14 +456,19 @@ var ContainerManager = class {
|
|
|
456
456
|
console.log(`
|
|
457
457
|
\u{1F680} Preparing ${containers.size} containers...`);
|
|
458
458
|
const pullAndStartPromises = Array.from(containers.entries()).map(async ([id, container]) => {
|
|
459
|
+
const imageTag = `${container.image}:${container.tag || "latest"}`;
|
|
459
460
|
try {
|
|
460
|
-
const imageTag = `${container.image}:${container.tag || "latest"}`;
|
|
461
461
|
console.log(` Pulling ${imageTag}...`);
|
|
462
462
|
await this.pullImage(container.image, container.tag || "latest");
|
|
463
463
|
console.log(` \u2713 ${imageTag} ready`);
|
|
464
|
+
} catch (error) {
|
|
465
|
+
console.error(` \u274C Failed to pull ${imageTag}:`, error.message);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
try {
|
|
464
469
|
await this.startPersistentContainer(id, container);
|
|
465
470
|
} catch (error) {
|
|
466
|
-
console.error(` \u274C Failed to
|
|
471
|
+
console.error(` \u274C Failed to start ${container.name || container.image}:`, error.message);
|
|
467
472
|
}
|
|
468
473
|
});
|
|
469
474
|
await Promise.all(pullAndStartPromises);
|
|
@@ -475,21 +480,23 @@ var ContainerManager = class {
|
|
|
475
480
|
async startPersistentContainer(containerId, metadata) {
|
|
476
481
|
const containerName = `noosphere-${metadata.name}`;
|
|
477
482
|
const imageTag = `${metadata.image}:${metadata.tag || "latest"}`;
|
|
483
|
+
const existingContainer = this.docker.getContainer(containerName);
|
|
478
484
|
try {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
} else {
|
|
485
|
+
const inspect = await existingContainer.inspect();
|
|
486
|
+
if (inspect.State.Running) {
|
|
487
|
+
console.log(` \u2713 Container ${containerName} already running`);
|
|
488
|
+
this.persistentContainers.set(containerId, existingContainer);
|
|
489
|
+
return;
|
|
490
|
+
} else {
|
|
491
|
+
try {
|
|
487
492
|
await existingContainer.start();
|
|
488
493
|
console.log(` \u2713 Started existing container ${containerName}`);
|
|
489
494
|
this.persistentContainers.set(containerId, existingContainer);
|
|
490
495
|
return;
|
|
496
|
+
} catch (startErr) {
|
|
497
|
+
console.log(` Removing stopped container ${containerName} to recreate...`);
|
|
498
|
+
await existingContainer.remove({ force: true });
|
|
491
499
|
}
|
|
492
|
-
} catch (err) {
|
|
493
500
|
}
|
|
494
501
|
} catch (err) {
|
|
495
502
|
}
|