# Monitor Config

Configuration for managing process monitoring, window management, and logging settings.

## Options

Input defaults are applied by the schema. Nested defaults are shown separately from their parent object. See [configuration reference conventions](/reference/cli/config-loading/#configuration-reference-conventions).

### `apps`

**Input type:** `object[]`

**Required:** No

**Input default:** `[]`

A list of apps to launch and monitor. Each app can be configured with PM2 settings, window management options, and logging preferences.

For detailed app configuration options, see [App Config](#app-config).

### `deleteExistingBeforeConnect`

**Input type:** `boolean`

**Required:** No

**Input default:** `true`

When enabled, deletes existing PM2 processes before connecting. Useful for volatile apps or when node processes might quit unexpectedly, ensuring a clean slate on startup.

### `windowsApi`

**Input type:** `object`

**Required:** No

**Input default:** `{}`

Advanced configuration for the Windows API, used for managing foreground/minimized/hidden windows. Window operations are Windows-only; PM2 process management and logging work independently of them. See [Windows window management](/reference/monitor/#windows-window-management) for platform and installation details.

#### `debounceDelay`

**Input type:** `number`

**Required:** No

**Input default:** `3000`

The delay (in milliseconds) until windows are ordered after launch. If your app takes a long time to open all of its windows, set this to a higher value to ensure it can be on top of the launchpad terminal window. Higher values also reduce CPU load if apps relaunch frequently.

### `shutdownOnExit`

**Input type:** `boolean`

**Required:** No

**Input default:** `true`

When enabled, listens for exit events to handle graceful shutdown.

## App Config

Each app in the `apps` array can have the following configuration:

### `pm2`

**Input type:** `StartOptions & object`

**Required:** Yes

**Input default:** —

PM2 configuration for the app. See [PM2 documentation](https://pm2.keymetrics.io/docs/usage/application-declaration/#attributes-available) for the full `StartOptions` API. The table below covers only the fields Launchpad declares explicitly, not every option accepted by PM2.

```typescript
monitor({
  apps: [{ pm2: { script: './app.js', out_file: './app-out.log' } }],
});
```

| Field        | Input type | Required | Input default | Meaning                      |
| ------------ | ---------- | -------- | ------------- | ---------------------------- |
| `out_file`   | `string`   | No       | —             | The file to write stdout to. |
| `error_file` | `string`   | No       | —             | The file to write stderr to. |

### `windows`

**Input type:** `object`

**Required:** No

**Input default:** `{}`

Settings for window management on Windows. All flags default to `false` and apply to the app’s visible top-level windows matched by its PM2 process ID.

Window operations are scheduled after launch using `windowsApi.debounceDelay`. They run asynchronously; the existing PM2 configuration and launch ordering are unchanged. On non-Windows platforms these settings do not perform window operations.

#### `foreground`

**Input type:** `boolean`

**Required:** No

**Input default:** `false`

Request foreground placement after launch. Windows focus restrictions can prevent activation.

#### `minimize`

**Input type:** `boolean`

**Required:** No

**Input default:** `false`

Minimize windows after launch.

#### `hide`

**Input type:** `boolean`

**Required:** No

**Input default:** `false`

Hide windows after launch. Hidden windows may interfere with GUI-based apps.

### `logging`

**Input type:** `object`

**Required:** No

**Input default:** `{}`

Settings for log management:

#### `logToLaunchpadDir`

**Input type:** `boolean`

**Required:** No

**Input default:** `true`

Route logs to launchpad’s directory

#### `mode`

**Input type:** `"file" | "bus"`

**Required:** No

**Input default:** `"bus"`

Log capture method (‘bus’ or ‘file’)

#### `showStdout`

**Input type:** `boolean`

**Required:** No

**Input default:** `true`

Include stdout output

#### `showStderr`

**Input type:** `boolean`

**Required:** No

**Input default:** `true`

Include stderr output
