pmcf 1.64.2 → 1.64.4

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.64.2",
3
+ "version": "1.64.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -297,7 +297,7 @@ export class Base {
297
297
 
298
298
  *findServices(filter) {
299
299
  if (this.owner) {
300
- yield* this.owner?.findServices(filter);
300
+ yield* this.owner.findServices(filter);
301
301
  }
302
302
  }
303
303
 
package/src/cluster.mjs CHANGED
@@ -75,9 +75,15 @@ export class Cluster extends Host {
75
75
  const name = `keepalived-${host.name}`;
76
76
  const packageStagingDir = join(stagingDir, name);
77
77
 
78
- const cfg = ["global_defs {", " notification_email {", " " + this.administratorEmail, " }",
78
+ const cfg = [
79
+ "global_defs {",
80
+ " notification_email {",
81
+ " " + this.administratorEmail,
82
+ " }",
79
83
  " smtp_server 192.168.1.1",
80
- "}"];
84
+ ` notification_email_from keepalived@${host.domainName}`,
85
+ "}"
86
+ ];
81
87
 
82
88
  for (const cluster of [...this.owner.clusters()].sort((a, b) =>
83
89
  a.name.localeCompare(b.name)
@@ -101,7 +107,6 @@ export class Cluster extends Host {
101
107
  cfg.push("");
102
108
 
103
109
  for (const service of cluster.findServices({ type: "http" })) {
104
- console.log("S", service.host.name, service.name);
105
110
  cfg.push(`virtual_server ${cluster.rawAddress} ${service.port} {`);
106
111
  cfg.push(" delay_loop 6");
107
112
  cfg.push(" lb_algo wlc");
@@ -109,13 +114,19 @@ export class Cluster extends Host {
109
114
  cfg.push(` protocol ${service.protocol.toUpperCase()}`);
110
115
 
111
116
  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(" }");
117
+ const memberService = member.findService({ type: service.type });
118
+
119
+ cfg.push(
120
+ ` real_server ${member.rawAddress} ${memberService.port} {`
121
+ );
122
+ cfg.push(` weight ${memberService.weight}`);
123
+
124
+ switch (service.protocol) {
125
+ case "tcp":
126
+ cfg.push(` TCP_CHECK {`);
127
+ cfg.push(" connect_timeout 3");
128
+ cfg.push(" }");
129
+ break;
119
130
  }
120
131
 
121
132
  cfg.push(" }");
package/src/host.mjs CHANGED
@@ -263,15 +263,18 @@ export class Host extends Base {
263
263
  }
264
264
 
265
265
  *findServices(filter) {
266
- for (const service of this.#services) {
267
- if (
268
- !filter ||
269
- filter.type === "*" ||
270
- filter.type === service.type ||
271
- filter.name === service.name
272
- ) {
273
- yield service;
266
+ if (filter) {
267
+ for (const service of this.#services) {
268
+ if (
269
+ filter.type === "*" ||
270
+ filter.type === service.type ||
271
+ filter.name === service.name
272
+ ) {
273
+ yield service;
274
+ }
274
275
  }
276
+ } else {
277
+ yield* this.#services;
275
278
  }
276
279
  }
277
280
 
package/src/service.mjs CHANGED
@@ -131,7 +131,14 @@ export class Service extends Base {
131
131
  }
132
132
 
133
133
  get weight() {
134
- return this.#weight || this.owner.weight || 0;
134
+ if (this.#weight !== undefined) {
135
+ return this.#weight;
136
+ }
137
+ if (this.owner.weight !== undefined) {
138
+ return this.owner.weight;
139
+ }
140
+
141
+ return 1;
135
142
  }
136
143
 
137
144
  set type(value) {