Skip to content

Commit

Permalink
use stop command to shutdown server + bump version to 0.0.26 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgao1996 authored Feb 7, 2025
1 parent 0f12393 commit 5f7c192
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions workspace/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion workspace/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aptos-labs/workspace",
"version": "0.0.25",
"version": "0.0.26",
"license": "Apache-2.0",
"bin": {
"aptos-workspace": "./dist/internal/cli.js",
Expand Down
26 changes: 14 additions & 12 deletions workspace/src/internal/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class TestNode {
const cliCommand = "npx";
const cliArgs: string[] = ["aptos", "workspace", "run"];

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

const rl = readline.createInterface({
input: childProcess.stdout,
Expand Down Expand Up @@ -122,21 +122,23 @@ export class TestNode {

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

const process = this.info.process;
kill(this.info.process.pid, 'SIGINT', (err) => {
if (err) {
reject(err);
return;
}

process.on('exit', (code, signal) => {
resolve(true)
});
const timeout = setTimeout(() => {
reject(new Error("workspace server process failed to exit within given timeout (90s)"));
}, 90000);

// TODO: timeout?
});
try {
process.stdin.write("stop\n");

process.on("exit", (code, signal) => {
resolve(true);
});
} catch (err) {
reject(err);
}
});
}
}
4 changes: 2 additions & 2 deletions workspace/src/internal/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChildProcessByStdio, ChildProcessWithoutNullStreams } from "child_process";
import { Readable } from "stream";
import { Writable, Readable } from "stream";

export type NodeInfo = {
process: ChildProcessByStdio<null, Readable, null>;
process: ChildProcessByStdio<Writable, Readable, null>;
rest_api_port: number;
faucet_port: number;
indexer_port: number;
Expand Down
1 change: 1 addition & 0 deletions workspace/src/tasks/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const getDevDependenciesToInstallCommand = async (
result: PromptResult
): Promise<string[]> => {
if (result.language === "ts") {
REQUIRED_DEV_DEPENDENCIES["@aptos-labs/aptos-cli"] = "^1.0.2";
REQUIRED_DEV_DEPENDENCIES["@types/chai"] = "4";
REQUIRED_DEV_DEPENDENCIES["@types/mocha"] = "^10.0.7";
REQUIRED_DEV_DEPENDENCIES["typescript"] = "^5.7.3";
Expand Down
2 changes: 1 addition & 1 deletion workspace/src/tasks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function checkAptosVersion(): Promise<void> {
}

const version = versionMatch[1];
const minimumVersion = "6.0.2";
const minimumVersion = "6.1.1";

if (semver.lt(version, minimumVersion)) {
return reject(
Expand Down

0 comments on commit 5f7c192

Please sign in to comment.