Skip to content

Commit

Permalink
Test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Dec 11, 2024
1 parent 9303ec2 commit 9a8bd5c
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions lib/hsm-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,11 @@ const spawnProcessVersion5 = async (serverPath, port, keyPath, latestBlockHash,
`-p8888 > /bundle/tcpsigner.log 2>&1 &`
];

// const tcpsignerCommand = `${serverPath}/tcpsigner -p${port} --c=${latestBlockHash} --difficulty=0x${difficultyTarget.toString(16).padStart(2, '0')} -k keys.json -p8888 > /bundle/tcpsigner.log 2>&1 &`;

console.log('tcpsignerCommand: ', tcpsignerCommand)

childProcess.spawn(tcpsignerCommand, args, { stdio: 'inherit', shell: true });

await wait(2000);
await portUtils.waitForPort('localhost', port);

const tcpsignerManagerArgs = [
`-b0.0.0.0`,
Expand Down Expand Up @@ -273,7 +271,7 @@ HSMRunner.prototype.spawnProcess = function() {
}
}

HSMRunner.prototype.start = function() {
HSMRunner.prototype.start = async function() {
if (this.isRunning()) {
throw "HSM already started";
}
Expand All @@ -294,39 +292,41 @@ HSMRunner.prototype.start = function() {
this.port = selectedPorts[0];
}

this.process = this.spawnProcess();
if (this.process.stdout) {
if (this.options.stdout != null) {
this.process.stdout.pipe(this.options.stdout);
} else {
this.process.stdout.pipe(devnull());
this.spawnProcess().then(process => {
this.process = process;
if (this.process.stdout) {
if (this.options.stdout != null) {
this.process.stdout.pipe(this.options.stdout);
} else {
this.process.stdout.pipe(devnull());
}
}
}

if (this.process.stderr) {
if (this.options.stderr != null) {
this.process.stderr.pipe(this.options.stderr);
} else {
this.process.stderr.pipe(devnull());
if (this.process.stderr) {
if (this.options.stderr != null) {
this.process.stderr.pipe(this.options.stderr);
} else {
this.process.stderr.pipe(devnull());
}
}
}

this.running = false;

this.process.on('exit', () => {
this.running = false;
});

this.client = HsmClient.getClient(this.options.host, this.port);
this.process.on('exit', () => {
this.running = false;
});

return executeWithRetries(
() => {
return this.getPublicKey();
},
10,
1000).then((r) => {
this.running = true;
return r;
this.client = HsmClient.getClient(this.options.host, this.port);

return executeWithRetries(
() => {
return this.getPublicKey();
},
10,
1000).then((r) => {
this.running = true;
return r;
});
});
});
};
Expand Down

0 comments on commit 9a8bd5c

Please sign in to comment.