Skip to content

Commit

Permalink
[ipc] clarify how to debug IPC servers
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosiakov <[email protected]>
  • Loading branch information
akosyakov committed Dec 4, 2017
1 parent c7eea4e commit b4dd8fe
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 12 deletions.
63 changes: 51 additions & 12 deletions dev-packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

`theia` is a command line tool to manage Theia applications.

- [**Getting started**](#getting-started)
- [**Configure**](#configure)
- [**Build Target**](#build-target)
- [**Using latest builds**](#using-latest-builds)
- [**Building**](#building)
- [**Rebuilding native modules**](#rebuilding-native-modules)
- [**Running**](#running)
- [**Debugging**](#debugging)

## Getting started

Install `@theia/cli` as a dev dependency in your application.
Expand Down Expand Up @@ -43,15 +52,45 @@ If you set `next` in your theia config, then Theia will prefer `next` over `late
}
```

## Run

- `theia clean` - remove the built output (`lib` folder) and the generated configurations
- `theia generate` - generate configurations for the given target
- `theia copy` - copy static resources to the built output
- `theia build` - package the frontend code with webpack
- arguments passed to webpack, e.g. `theia build --watch` to package the frontend code incrementally
- `theia rebuild` - rebuild native modules for the given target
- `theia start` - start the backend node or electron process
- by default on port `3000` for the browser target
- by default on host `localhost` for the electron target
- arguments passed to a backend process, e.g. `theia start --port=3001` to start the backend on port `3001`
## Building

To build once:

theia build

In order to rebuild on each change:

theia build --watch

In order to clean up the build result:

theia clean

Arguments are passed directly to [webpack](https://webpack.js.org/), use `--help` to learn which options are supported.

## Rebuilding native modules

In order to run electron one should rebuild native node modules for an electron version:

theia rebuild

To rollback native modules change the target to `browser` and run the command again.

## Running

To run the backend server:

theia start

For the browser target a server is started on http://localhost:3000 by default.
For the electron target a server is started on `localhost` host with the dynamically allocated port by default.

Arguments are passed directly to a server, use `--help` to learn which options are supported.

## Debugging

To debug the backend server:

theia start --inspect

Theia CLI accepts `--inspect` node flag: https://nodejs.org/en/docs/inspector/#command-line-options.
11 changes: 11 additions & 0 deletions doc/Developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For Windows instructions [click here](#building-on-windows).
- [Debug the browser example's frontend and backend at the same time](#debug-the-browser-examples-frontend-and-backend-at-the-same-time)
- [Debug the Electron example's backend](#debug-the-electron-examples-backend)
- [Debug the Electron example's frontend](#debug-the-electron-examples-frontend)
- [Debug IPC servers](#debug-ipc-servers)
- [**Testing**](#testing)
- [**Code coverage**](#code-coverage)
- [**Building on Windows**](#building-on-windows)
Expand Down Expand Up @@ -190,6 +191,16 @@ Note that some breakpoints don't hit because of [this issue](https://github.com/
- Start the backend by using `yarn run start`.
- In Electron: Help -> Toggle Electron Developer Tools.

### Debug IPC servers

- Pass `--${server-name}-inspect` arg to the backend server.
- For example `--nfsw-watcher-inspect=0` to inspect nfsw watcher processes with dynamic port allocation.
- All variations of `--inspect` flag are supported: https://nodejs.org/en/docs/inspector/#command-line-options.
- Attach the debugger to the logged port.

In order to look up `server-name` run the backend server with `--logLevel=debug` flag to enable logging of IPC servers instantiation.
You should be able to see message of `[${server-name}: ${server-PID}]: IPC started` format, like `[nsfw-watcher: 37557] IPC started`.

## Testing

See the [testing](Testing.md) documentation.
Expand Down

0 comments on commit b4dd8fe

Please sign in to comment.