MCPcopy
hub / github.com/louislam/dockge / getServiceStatusList

Method getServiceStatusList

backend/stack.ts:499–532  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

497 }
498
499 async getServiceStatusList() {
500 let statusList = new Map<string, number>();
501
502 try {
503 let res = await childProcessAsync.spawn("docker", [ "compose", "ps", "--format", "json" ], {
504 cwd: this.path,
505 encoding: "utf-8",
506 });
507
508 if (!res.stdout) {
509 return statusList;
510 }
511
512 let lines = res.stdout?.toString().split("\n");
513
514 for (let line of lines) {
515 try {
516 let obj = JSON.parse(line);
517 if (obj.Health === "") {
518 statusList.set(obj.Service, obj.State);
519 } else {
520 statusList.set(obj.Service, obj.Health);
521 }
522 } catch (e) {
523 }
524 }
525
526 return statusList;
527 } catch (e) {
528 log.error("getServiceStatusList", e);
529 return statusList;
530 }
531
532 }
533}

Callers 1

createMethod · 0.80

Calls 2

setMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected