pmcf 1.62.0 → 1.63.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.62.0",
3
+ "version": "1.63.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -51,6 +51,10 @@ export class Cluster extends Host {
51
51
  return this.#backups;
52
52
  }
53
53
 
54
+ get members() {
55
+ return this.masters.union(this.backups);
56
+ }
57
+
54
58
  async *preparePackages(stagingDir) {
55
59
  const result = {
56
60
  sources: [],
@@ -71,7 +75,9 @@ export class Cluster extends Host {
71
75
  const name = `keepalived-${host.name}`;
72
76
  const packageStagingDir = join(stagingDir, name);
73
77
 
74
- const cfg = [];
78
+ const cfg = ["global_defs {", " notification_email {", " " + this.administratorEmail, " }",
79
+ " smtp_server 192.168.1.1",
80
+ "}"];
75
81
 
76
82
  for (const cluster of [...this.owner.clusters()].sort((a, b) =>
77
83
  a.name.localeCompare(b.name)
@@ -93,6 +99,31 @@ export class Cluster extends Host {
93
99
  cfg.push(" }");
94
100
  cfg.push("}");
95
101
  cfg.push("");
102
+
103
+ for (const service of cluster.findServices({ type: "http" })) {
104
+ console.log("S", service.host.name, service.name);
105
+ cfg.push(`virtual_server ${cluster.rawAddress} ${service.port} {`);
106
+ cfg.push(" delay_loop 6");
107
+ cfg.push(" lb_algo wlc");
108
+ cfg.push(" persistence_timeout 600");
109
+ cfg.push(` protocol ${service.protocol.toUpperCase()}`);
110
+
111
+ for (const member of this.members) {
112
+ cfg.push(` real_server ${member.rawAddress} ${service.port} {`);
113
+ cfg.push(" weight 100");
114
+
115
+ if (service.protocol === "tcp") {
116
+ cfg.push(` TCP_CHECK {`);
117
+ cfg.push(" connect_timeout 3");
118
+ cfg.push(" }");
119
+ }
120
+
121
+ cfg.push(" }");
122
+ }
123
+
124
+ cfg.push("}");
125
+ cfg.push("");
126
+ }
96
127
  }
97
128
 
98
129
  await writeLines(
package/src/host.mjs CHANGED
@@ -254,8 +254,12 @@ export class Host extends Base {
254
254
  return this.#services;
255
255
  }
256
256
 
257
- set services(services) {
258
- this.#services.push(services);
257
+ set services(service) {
258
+ const present = this.#services.find(s => s.name === service.name);
259
+
260
+ if (!present) {
261
+ this.#services.push(service);
262
+ }
259
263
  }
260
264
 
261
265
  *findServices(filter) {
@@ -381,6 +381,7 @@ export class Cluster extends Host {
381
381
  get masters(): Set<any>;
382
382
  set backups(value: Set<any>);
383
383
  get backups(): Set<any>;
384
+ get members(): Set<any>;
384
385
  preparePackages(stagingDir: any): AsyncGenerator<{
385
386
  sources: any[];
386
387
  properties: {
package/types/host.d.mts CHANGED
@@ -151,7 +151,7 @@ export class Host extends Base {
151
151
  get provides(): Set<any>;
152
152
  set replaces(value: Set<any>);
153
153
  get replaces(): Set<any>;
154
- set services(services: any[]);
154
+ set services(service: any[]);
155
155
  get services(): any[];
156
156
  _traverse(...args: any[]): boolean;
157
157
  set deployment(value: any);