Skip to content

Commit c355593

Browse files
committed
Update start scripts and subprocess command handling
Modified package.json start scripts to run from the build directory with a specific config file and port. Updated HTTPGatewayWrapper to launch the subprocess using the currently executing script path, ensuring compatibility with both source and build environments.
1 parent c830500 commit c355593

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"main": "build/index.js",
77
"scripts": {
88
"build": "bun build src/index.ts --outdir build --target node --format esm --sourcemap=external",
9-
"start": "bun run src/index.ts --mode=sse",
10-
"start:stdio": "bun run src/index.ts --mode=stdio",
9+
"start": "bun run build/index.js --config=examples/coingecko-config.yaml --mode=sse --port=8000",
10+
"start:stdio": "bun run build/index.js --config=examples/coingecko-config.yaml --mode=stdio",
1111
"dev": "bun run src/index.ts --mode=sse",
1212
"dev:stdio": "bun run src/index.ts --mode=stdio",
1313
"type-check": "tsc --noEmit",

src/transports/http-wrapper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ class HTTPGatewayWrapper {
4646
// Gateway subprocess command - use wrapper config (no payment checking in subprocess)
4747
// The HTTP layer handles all payment verification
4848
// IMPORTANT: Subprocess must run in STDIO mode, not SSE mode
49-
const gatewayPath = new URL('../index.ts', import.meta.url).pathname;
49+
50+
// Just re-run the same script we're currently running, but in STDIO mode
51+
// process.argv[1] is the path to the currently executing script (works for both src and build)
52+
// Use 'bun' directly (not 'bun run') to execute the script without package.json interference
53+
const currentScript = process.argv[1]!;
5054
const wrapperConfigPath = configPath.replace('.yaml', '-wrapper.yaml').replace('.json', '-wrapper.json');
51-
this.gatewayCommand = ['bun', 'run', gatewayPath, '--mode=stdio', `--config=${wrapperConfigPath}`];
55+
this.gatewayCommand = ['bun', currentScript, '--mode=stdio', `--config=${wrapperConfigPath}`];
5256

5357
logger.info(`Gateway subprocess will use config: ${wrapperConfigPath}`);
5458
}

0 commit comments

Comments
 (0)