Skip to content

Commit

Permalink
Easier debugging of app-executor sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
gogwilt committed Mar 19, 2024
1 parent 2b2e4ae commit a2a8c4f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,21 @@ In VS Code, ESLint is configured to run automatically on save. We also recommend

## Node Executor

Certain nodes need to run in the "Node Executor." This starts a "sidecar" process, which can be difficult to develop with. If you are developing a feature or plugin that requires the Node Executor, consider running the node executor directly:
Certain nodes need to run in the "Node Executor." This starts a "sidecar" process, which can be difficult to develop with. If you are developing a feature or plugin that requires the Node Executor, consider using the following setup:

Run a watcher for code changes:

```
cd packages/app-executor
yarn start --port 21889
cd packages/core
yarn watch
```

This will reduce the build time. However, you will still need to restart the sidecar whenever you make a code change.
Then, start the app-executor in dev mode:

```
cd packages/app-executor
yarn dev
```

## Releasing

Expand Down
4 changes: 4 additions & 0 deletions packages/app-executor/bin/executor.mts
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,8 @@ const rivetDebugger = startDebuggerServer({
},
});

process.on('SIGTERM', () => {
rivetDebugger.webSocketServer.close();
});

console.log(`Node.js executor started on port ${port}.`);
1 change: 1 addition & 0 deletions packages/app-executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "module",
"scripts": {
"build": "tsx scripts/build-executor.mts",
"dev": "tsx watch --inspect=9228 --experimental-network-imports bin/executor.mts",
"start": "yarn build && node --experimental-network-imports bin/executor-bundle.cjs",
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.mts bin"
},
Expand Down
12 changes: 10 additions & 2 deletions packages/core/bundle.esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,26 @@ const aliasModule = (moduleFrom: string, moduleTo: string): esbuild.Plugin => ({
},
});

esbuild.build({
const options: esbuild.BuildOptions = {
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
outfile: 'dist/cjs/bundle.cjs',
format: 'cjs',
target: 'node16',
packages: 'external',
sourcemap: true,
plugins: [
aliasModule('lodash-es', 'lodash'),
aliasModule('p-queue', 'p-queue-6'),
aliasModule('emittery', 'emittery-0-13'),
aliasModule('p-retry', 'p-retry-4'),
],
});
};

if (process.argv.includes('--watch')) {
const context = await esbuild.context(options);
await context.watch();
} else {
await esbuild.build(options);
}
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"prepack": "yarn build && cp -r ../../LICENSE ../../README.md .",
"publish": "yarn npm publish --access public",
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./src",
"test": "tsx --test test/**/*.test.ts"
"test": "tsx --test test/**/*.test.ts",
"watch": "tsc -b -w"
},
"dependencies": {
"@gentrace/core": "^2.2.5",
Expand Down

0 comments on commit a2a8c4f

Please sign in to comment.