@metric-im/administrate 1.1.7 → 1.1.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.
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "permissions": {
3
3
  "allow": [
4
- "Read(//home/msprague/workspace/sitewell/**)",
5
- "Read(//home/msprague/workspace/rootz/data-wallet-demos/**)"
4
+ "Read(//home/msprague/workspace/rootz/epistery/docs/**)",
5
+ "Read(//home/msprague/workspace/rootz/epistery/src/**)",
6
+ "Read(//home/msprague/workspace/rootz/epistery/**)",
7
+ "Read(//home/msprague/workspace/rootz/rhonda/node_modules/epistery/**)",
8
+ "Read(//home/msprague/workspace/rootz/rhonda/**)",
9
+ "Read(//home/msprague/workspace/metric-im/account-control/**)",
10
+ "Bash(sed:*)",
11
+ "Bash(git checkout:*)"
6
12
  ],
7
13
  "deny": [],
8
14
  "ask": []
9
15
  }
10
- }
16
+ }
package/multisite.mjs CHANGED
@@ -15,6 +15,7 @@ export class MultiSite {
15
15
  this.app = app;
16
16
  this.options = options || {};
17
17
  this.sites = {};
18
+ this.spawning = new Set(); // Track domains currently being spawned
18
19
  this._spawnPort = (parseInt(this.options.spawnPort||0) || 53874);
19
20
  this.usedPorts = new Set();
20
21
  this.healthCheckIntervals = new Map();
@@ -325,11 +326,25 @@ export class MultiSite {
325
326
  res.status(502).send('Bad Gateway. Try reloading.');
326
327
  }
327
328
  } else {
328
- this.sites[domain] = Site.Clone(domain,this);
329
- // Retry the request after spawning
330
- setTimeout(() => {
331
- res.redirect(`//${req.hostname}${req.url}`);
332
- }, 2000);
329
+ // Check if already spawning to prevent race condition
330
+ if (this.spawning.has(domain)) {
331
+ // Site is already being spawned, wait for it
332
+ setTimeout(() => {
333
+ res.redirect(`//${req.hostname}${req.url}`);
334
+ }, 2000);
335
+ } else {
336
+ // Mark as spawning
337
+ this.spawning.add(domain);
338
+ this.sites[domain] = Site.Clone(domain,this);
339
+ // Remove from spawning set after spawn completes
340
+ setTimeout(() => {
341
+ this.spawning.delete(domain);
342
+ }, 3000);
343
+ // Retry the request after spawning
344
+ setTimeout(() => {
345
+ res.redirect(`//${req.hostname}${req.url}`);
346
+ }, 2000);
347
+ }
333
348
  }
334
349
  });
335
350
  return router;
@@ -341,7 +356,7 @@ export class Site {
341
356
  this.options = options;
342
357
  this.parent = parent;
343
358
  try {
344
- const envars = JSON.parse(process.env.SITE_ENV||{});
359
+ const envars = JSON.parse(process.env.SITE_ENV||'{}');
345
360
  Object.assign(this.options.env,envars[this.name]||{});
346
361
  } catch(e) {
347
362
  console.log(`Unable to parse SITE_ENV... continuing: ${e.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metric-im/administrate",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Tools for site administration",
5
5
  "homepage": "https://github.com/metric-im/administrate#readme",
6
6
  "bugs": {
@@ -21,7 +21,7 @@
21
21
  "@metric-im/componentry": "^1.4.4",
22
22
  "acme-client": "^5.4.0",
23
23
  "axios": "^1.7.0",
24
- "epistery": "^1.1.0",
24
+ "epistery": "^1.1.4",
25
25
  "express": "^5.1.0",
26
26
  "moment": "^2.30.1"
27
27
  }