@peerbit/server 5.5.0-aeb9685 → 5.6.0-1c918e0
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/dist/ui/index.html
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
Learn how to configure a non-root public URL by running `npm run build`.
|
|
24
24
|
-->
|
|
25
25
|
<title>Peerbit</title>
|
|
26
|
-
<script type="module" crossorigin src="/assets/index-
|
|
26
|
+
<script type="module" crossorigin src="/assets/index-BeFPnrza.js"></script>
|
|
27
27
|
<link rel="stylesheet" crossorigin href="/assets/index-CIfVvUo9.css">
|
|
28
28
|
</head>
|
|
29
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0-1c918e0",
|
|
4
4
|
"author": "dao.xyz",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"lint": "aegir lint"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@peerbit/test-lib": "0.0.1-
|
|
70
|
-
"@peerbit/test-utils": "2.1.57-
|
|
69
|
+
"@peerbit/test-lib": "0.0.1-1c918e0",
|
|
70
|
+
"@peerbit/test-utils": "2.1.57-1c918e0",
|
|
71
71
|
"@types/yargs": "17.0.24",
|
|
72
72
|
"aws-sdk": "^2.1259.0",
|
|
73
73
|
"dotenv": "^16.1.4",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"axios": "^1.4.0",
|
|
80
80
|
"chalk": "^5.3.0",
|
|
81
|
-
"peerbit": "4.1.46-
|
|
81
|
+
"peerbit": "4.1.46-1c918e0",
|
|
82
82
|
"yargs": "^17.7.2",
|
|
83
83
|
"tar-stream": "^3.1.7",
|
|
84
84
|
"tmp": "^0.2.1",
|
package/src/aws.ts
CHANGED
|
@@ -249,40 +249,58 @@ export const launchNodes = async (properties: {
|
|
|
249
249
|
);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
// wait for instance
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const foundIps: string[] = [];
|
|
262
|
-
for (const out of instanceOut.Instances) {
|
|
263
|
-
const foundInstance = foundInstances.find(
|
|
264
|
-
(x) => x!.InstanceId === out.InstanceId!,
|
|
265
|
-
);
|
|
266
|
-
if (!foundInstance!.PublicIpAddress) {
|
|
267
|
-
await delay(3000);
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
foundIps.push(foundInstance!.PublicIpAddress!);
|
|
271
|
-
}
|
|
272
|
-
let publicIps: string[] = foundIps;
|
|
252
|
+
// wait for AWS to recognize the new instance IDs and for public IPs to be assigned
|
|
253
|
+
const instanceIds = instanceOut.Instances.map((x) => x.InstanceId!);
|
|
254
|
+
const timeoutMs = 3 * 60 * 1000; // 3 minutes
|
|
255
|
+
const pollIntervalMs = 5000;
|
|
256
|
+
const start = Date.now();
|
|
257
|
+
let foundInstances: Array<{
|
|
258
|
+
InstanceId?: string;
|
|
259
|
+
PublicIpAddress?: string;
|
|
260
|
+
}> = [];
|
|
273
261
|
|
|
274
|
-
|
|
275
|
-
|
|
262
|
+
while (Date.now() - start < timeoutMs) {
|
|
263
|
+
try {
|
|
264
|
+
const info = await client.send(
|
|
265
|
+
new DescribeInstancesCommand({ InstanceIds: instanceIds }),
|
|
266
|
+
);
|
|
267
|
+
foundInstances =
|
|
268
|
+
info.Reservations?.flatMap((r) => r.Instances || []) || [];
|
|
269
|
+
const allPresent = foundInstances.length >= instanceIds.length;
|
|
270
|
+
const ips = new Map(
|
|
271
|
+
foundInstances
|
|
272
|
+
.filter((i) => i.InstanceId && i.PublicIpAddress)
|
|
273
|
+
.map((i) => [i.InstanceId!, i.PublicIpAddress!]),
|
|
274
|
+
);
|
|
275
|
+
const allHaveIp = instanceIds.every((id) => ips.has(id));
|
|
276
|
+
if (allPresent && allHaveIp) {
|
|
277
|
+
// reorder to original order
|
|
278
|
+
var publicIps = instanceIds.map((id) => ips.get(id)!);
|
|
279
|
+
if (publicIps.length > 0) {
|
|
280
|
+
// success
|
|
281
|
+
return publicIps.map((v, ix) => {
|
|
282
|
+
return {
|
|
283
|
+
instanceId: instanceOut.Instances![ix].InstanceId!,
|
|
284
|
+
publicIp: v,
|
|
285
|
+
name: names[ix],
|
|
286
|
+
region: regionString,
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} catch (e: any) {
|
|
292
|
+
// AWS eventual consistency: sometimes returns InvalidInstanceID.NotFound immediately after RunInstances
|
|
293
|
+
const code = e?.Code || e?.name || e?.code;
|
|
294
|
+
if (code !== "InvalidInstanceID.NotFound") {
|
|
295
|
+
throw e;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
await delay(pollIntervalMs);
|
|
276
299
|
}
|
|
277
300
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
publicIp: v,
|
|
282
|
-
name: names[ix],
|
|
283
|
-
region: regionString,
|
|
284
|
-
};
|
|
285
|
-
}); // TODO types
|
|
301
|
+
throw new Error(
|
|
302
|
+
"Timed out waiting for instances to be describe-able with public IPs",
|
|
303
|
+
);
|
|
286
304
|
};
|
|
287
305
|
|
|
288
306
|
export const terminateNode = async (properties: {
|