# ServerProcess

> **Class** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess)

Manages a `langgraph dev` server subprocess.

Focuses on subprocess lifecycle (start, stop, restart) and health checking.
Env-var management for restarts (e.g. configuration changes requiring a full
restart) is handled by `_scoped_env_overrides`, keeping this class focused
on process management.

## Signature

```python
ServerProcess(
    self,
    *,
    host: str = _DEFAULT_HOST,
    port: int = _EPHEMERAL_PORT,
    config_dir: str | Path | None = None,
    owns_config_dir: bool = False,
    scaffold: Callable[[Path], None] | None = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `host` | `str` | No | Host to bind the server to. (default: `_DEFAULT_HOST`) |
| `port` | `int` | No | Initial port to bind the server to. Defaults to `_EPHEMERAL_PORT` (0), so `start()` picks a free port and avoids squatting the well-known `langgraph dev` default (2024).  An explicit port is honored, but `start()` still falls back to a free port if it is already in use. (default: `_EPHEMERAL_PORT`) |
| `config_dir` | `str \| Path \| None` | No | Directory containing `langgraph.json`. (default: `None`) |
| `owns_config_dir` | `bool` | No | When `True`, the server will delete `config_dir` on `stop()`. (default: `False`) |
| `scaffold` | `Callable[[Path], None] \| None` | No | Optional callable that (re)generates the working directory's `langgraph.json` and supporting files. When the config is missing at `start()` (e.g. the temp dir was purged between the initial boot and a later `/restart`), it is invoked to rebuild the workspace instead of failing. (default: `None`) |

## Constructors

```python
__init__(
    self,
    *,
    host: str = _DEFAULT_HOST,
    port: int = _EPHEMERAL_PORT,
    config_dir: str | Path | None = None,
    owns_config_dir: bool = False,
    scaffold: Callable[[Path], None] | None = None,
) -> None
```

| Name | Type |
|------|------|
| `host` | `str` |
| `port` | `int` |
| `config_dir` | `str \| Path \| None` |
| `owns_config_dir` | `bool` |
| `scaffold` | `Callable[[Path], None] \| None` |


## Properties

- `host`
- `port`
- `config_dir`
- `url`
- `running`

## Methods

- [`start()`](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess/start)
- [`wait_for_graph_ready()`](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess/wait_for_graph_ready)
- [`stop()`](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess/stop)
- [`update_env()`](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess/update_env)
- [`persist_env()`](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess/persist_env)
- [`restart()`](https://reference.langchain.com/python/deepagents-code/client/launch/server/ServerProcess/restart)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/e14e0adcbe78565ed3650e7f24b2a775d5437d25/libs/code/deepagents_code/client/launch/server.py#L540)