> ## Documentation Index
> Fetch the complete documentation index at: https://sysg.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# spawn

# spawn

Dynamically create child processes from parent services.

:::warning Deprecated
`sysg spawn` is deprecated. Use `sysg start --parent-pid <pid> --name <name> -- <command...>`.
:::

```sh theme={null}
$ sysg spawn --name worker_1 -- python worker.py
```

## Options

| Short | Long           | Description                                                          |
| ----- | -------------- | -------------------------------------------------------------------- |
| `-`   | `--name`       | Required. Unique identifier for spawned process                      |
| `-`   | `--ttl`        | Time-to-live in seconds (optional)                                   |
| `-`   | `--parent-pid` | Parent process ID (defaults to caller's parent PID if not specified) |
| `-`   | `--sys`        | Opt into privileged system mode. Requires running as root            |
| `-`   | `--log-level`  | Override the logging verbosity for the spawned process               |

## Examples

### Preferred replacement with `start`

```sh theme={null}
$ sysg start --parent-pid 12345 --name worker_1 -- python worker.py
$ 12345  # Returns PID
```

### Spawn a worker process

```sh theme={null}
$ sysg spawn --name worker_1 -- python worker.py
$ 12345  # Returns PID
```

### Spawn with time limit

Process automatically terminates after 1 hour:

```sh theme={null}
$ sysg spawn --name temp_worker \
  --ttl 3600 \
  -- ./process.sh
```

### Spawn with parent PID tracking

```sh theme={null}
$ sysg spawn --name api_worker \
  --parent-pid 12345 \
  -- node worker.js
```

## Requirements

:::info
The parent service must opt into dynamic spawning before it can create
children. Without `spawn: mode: dynamic`, spawn requests from that process are
rejected because SystemG has no authorized spawn tree for the parent.
:::

Parent service must be configured with:

```yaml theme={null}
services:
  orchestrator:
    command: "porki --role orchestrator --instructions instructions/INSTRUCTIONS.md"
    spawn:
      mode: dynamic
      limits:
        children: 10
        depth: 3
        descendants: 50
```

The parent can then spawn child processes dynamically within those limits.

## See also

* [Spawn configuration](/how-it-works/configuration#spawn-settings)
* [`status`](/how-it-works/commands/status) - View spawned processes
