mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-19 15:54:28 +00:00
chore: improve Docker network config reliability
This commit is contained in:
parent
18c6d3b792
commit
e8f5171d93
@ -107,6 +107,7 @@ export default class Dockerode {
|
||||
const container = await this.docker.createContainer({
|
||||
Image: this.IMAGE_NAME,
|
||||
HostConfig: {
|
||||
NetworkMode: NETWORK_NAME,
|
||||
AutoRemove: true,
|
||||
PortBindings: {
|
||||
[`${restPort}/tcp`]: [{ HostPort: restPort.toString() }],
|
||||
@ -116,6 +117,8 @@ export default class Dockerode {
|
||||
[`${discv5UdpPort}/udp`]: [{ HostPort: discv5UdpPort.toString() }]
|
||||
})
|
||||
},
|
||||
Dns: ["8.8.8.8"],
|
||||
Links: [],
|
||||
Mounts: args.rlnRelayEthClientAddress
|
||||
? [
|
||||
{
|
||||
@ -135,18 +138,19 @@ export default class Dockerode {
|
||||
[`${discv5UdpPort}/udp`]: {}
|
||||
})
|
||||
},
|
||||
Cmd: argsArrayWithIP
|
||||
});
|
||||
await container.start();
|
||||
|
||||
await Dockerode.network.connect({
|
||||
Container: container.id,
|
||||
EndpointConfig: {
|
||||
IPAMConfig: {
|
||||
IPv4Address: this.containerIp
|
||||
Cmd: argsArrayWithIP,
|
||||
NetworkingConfig: {
|
||||
EndpointsConfig: {
|
||||
[NETWORK_NAME]: {
|
||||
IPAMConfig: {
|
||||
IPv4Address: this.containerIp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
await container.start();
|
||||
|
||||
const logStream = fs.createWriteStream(logPath);
|
||||
|
||||
container.logs(
|
||||
|
@ -431,3 +431,20 @@ interface RpcInfoResponse {
|
||||
listenAddresses: string[];
|
||||
enrUri?: string;
|
||||
}
|
||||
|
||||
export async function verifyServiceNodesConnected(
|
||||
nodes: ServiceNode[]
|
||||
): Promise<void> {
|
||||
for (const node of nodes) {
|
||||
const peers = await node.peers();
|
||||
log.info(`Service node ${node.containerName} peers:`, peers.length);
|
||||
log.info(`Service node ${node.containerName} peers:`, peers);
|
||||
|
||||
if (nodes.length > 1 && peers.length === 0) {
|
||||
log.error(`Service node ${node.containerName} has no peers connected`);
|
||||
throw new Error(
|
||||
`Service node ${node.containerName} has no peers connected`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,9 @@ export async function runMultipleNodes(
|
||||
withoutFilter
|
||||
);
|
||||
|
||||
await verifyServiceNodesConnected(serviceNodes.nodes);
|
||||
if (numServiceNodes > 1) {
|
||||
await verifyServiceNodesConnected(serviceNodes.nodes);
|
||||
}
|
||||
|
||||
const wakuOptions: ProtocolCreateOptions = {
|
||||
staticNoiseKey: NOISE_KEY_1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user