Skip to content

Commit 5f7c192

Browse files
authored
use stop command to shutdown server + bump version to 0.0.26 (#58)
1 parent 0f12393 commit 5f7c192

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

workspace/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspace/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aptos-labs/workspace",
3-
"version": "0.0.25",
3+
"version": "0.0.26",
44
"license": "Apache-2.0",
55
"bin": {
66
"aptos-workspace": "./dist/internal/cli.js",

workspace/src/internal/node.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class TestNode {
3434
const cliCommand = "npx";
3535
const cliArgs: string[] = ["aptos", "workspace", "run"];
3636

37-
const childProcess = spawn(cliCommand, cliArgs, { detached: false, stdio: ['ignore', 'pipe', 'ignore'], shell: true });
37+
const childProcess = spawn(cliCommand, cliArgs, { detached: false, stdio: ['pipe', 'pipe', 'ignore'], shell: true });
3838

3939
const rl = readline.createInterface({
4040
input: childProcess.stdout,
@@ -122,21 +122,23 @@ export class TestNode {
122122

123123
public async stop() {
124124
await new Promise((resolve, reject) => {
125-
if (!this.info?.process?.pid) return;
125+
if (this.info == null) return;
126126

127127
const process = this.info.process;
128-
kill(this.info.process.pid, 'SIGINT', (err) => {
129-
if (err) {
130-
reject(err);
131-
return;
132-
}
133128

134-
process.on('exit', (code, signal) => {
135-
resolve(true)
136-
});
129+
const timeout = setTimeout(() => {
130+
reject(new Error("workspace server process failed to exit within given timeout (90s)"));
131+
}, 90000);
137132

138-
// TODO: timeout?
139-
});
133+
try {
134+
process.stdin.write("stop\n");
135+
136+
process.on("exit", (code, signal) => {
137+
resolve(true);
138+
});
139+
} catch (err) {
140+
reject(err);
141+
}
140142
});
141143
}
142144
}

workspace/src/internal/utils/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ChildProcessByStdio, ChildProcessWithoutNullStreams } from "child_process";
2-
import { Readable } from "stream";
2+
import { Writable, Readable } from "stream";
33

44
export type NodeInfo = {
5-
process: ChildProcessByStdio<null, Readable, null>;
5+
process: ChildProcessByStdio<Writable, Readable, null>;
66
rest_api_port: number;
77
faucet_port: number;
88
indexer_port: number;

workspace/src/tasks/init.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const getDevDependenciesToInstallCommand = async (
2626
result: PromptResult
2727
): Promise<string[]> => {
2828
if (result.language === "ts") {
29+
REQUIRED_DEV_DEPENDENCIES["@aptos-labs/aptos-cli"] = "^1.0.2";
2930
REQUIRED_DEV_DEPENDENCIES["@types/chai"] = "4";
3031
REQUIRED_DEV_DEPENDENCIES["@types/mocha"] = "^10.0.7";
3132
REQUIRED_DEV_DEPENDENCIES["typescript"] = "^5.7.3";

workspace/src/tasks/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function checkAptosVersion(): Promise<void> {
4545
}
4646

4747
const version = versionMatch[1];
48-
const minimumVersion = "6.0.2";
48+
const minimumVersion = "6.1.1";
4949

5050
if (semver.lt(version, minimumVersion)) {
5151
return reject(

0 commit comments

Comments
 (0)