@yz-social/civildefense.io 4.5.7 → 4.5.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/server/app.js CHANGED
@@ -46,6 +46,12 @@ const argv = yargs(hideBin(process.argv))
46
46
  default: 5,
47
47
  description: "Additional variable seconds (+/- variableSpacing/2) to add to fixedSpacing between each portal."
48
48
  })
49
+ .option('info', {
50
+ alias: 'i',
51
+ type: 'boolean',
52
+ default: true,
53
+ description: "Run with info logging."
54
+ })
49
55
  .option('verbose', {
50
56
  alias: 'v',
51
57
  type: 'boolean',
@@ -94,20 +100,28 @@ if (cluster.isPrimary) { // Parent process with portal webserver through which c
94
100
  }));
95
101
 
96
102
  app.listen(port);
97
- console.log('Listening on', port, 'and starting', argv.nPortals, 'nodes.');
103
+ console.log(new Date(), `Listening on ${port} and starting ${argv.nPortals} nodes on ${logicalCores} ${cpus()[0].model} logical cores.`);
98
104
  for (let i = 0; i < argv.nPortals; i++) {
99
105
  cluster.fork();
100
- await new Promise(resolve => setTimeout(resolve, 1e3));
106
+ await new Promise(resolve => setTimeout(resolve, 2e3)); // Number chosen to give an unspikey rise in packets/s.
101
107
  }
102
108
  } else {
103
109
  process.title = 'axona-starting';
104
110
  const { P2PWebNetwork, location } = await import('../index.js');
105
- const network = await P2PWebNetwork.create({region: location});
111
+ const network = await P2PWebNetwork.create({
112
+ region: location,
113
+ infoLogger: (...rest) => argv.info && console.log(new Date(), ...rest),
114
+ debugLogger: (...rest) => argv.verbose && console.log(new Date(), ...rest)
115
+ });
106
116
  process.title = 'axona-' + network.nodeIdentity.id;
107
- //let update = setInterval(() => network.info(network.peer.health().axonRoles.length, 'axons'), 10e3);
117
+ let update = setInterval(() => {
118
+ const roles = network.peer.health().axonRoles;
119
+ network.debug(roles.length, 'axons',
120
+ roles.reduce((total, role) => total + (role.isRoot ? 1 : 0), 0), 'roots');
121
+ }, 10e3);
108
122
  process.on('SIGINT', async () => { // Leave the network politely.
109
123
  console.log(process.title, 'Shutdown for Ctrl+C');
110
- //clearInterval(update)
124
+ clearInterval(update)
111
125
  await network.disconnect();
112
126
  process.exit(0);
113
127
  });
@@ -0,0 +1,7 @@
1
+ {
2
+ "uswest/80": "37.4852,-122.2364",
3
+ "useast/89": "40,-75",
4
+ "uscentle/88": "35,-83",
5
+ "easteu/47": "50,17",
6
+ "loc": "37,-122"
7
+ }
@@ -31,8 +31,8 @@ describe("Conversation", function () {
31
31
  let keep = true;
32
32
  let tag = "caching";
33
33
  class CacheConversation extends Conversation {
34
- update() { return keep && this; }
35
- initialize() { return keep && this; }
34
+ update(properties) { return keep && super.update(properties); }
35
+ initialize(properties) { return keep && super.initialize(properties); }
36
36
  }
37
37
  it("ends with explicit removal.", async function () {
38
38
  let initial = await Conversation.ensure({tag, agent, payload});