# Configuration

HakoRun is configured entirely through environment variables; the `Makefile` loads `.env` from the project root.

## Create the Config File

```bash
cp .env.example .env
```

Variables that are unset or fail to parse as numbers fall back to their defaults (`internal/utils/getEnv.go`).

## Server and Execution

| Variable | Default | Description |
|----------|---------|-------------|
| `HTTP_PORT` | `8080` | HTTP listen port |
| `CODE_MAX_SIZE` | `262144` (256 KiB) | Request body byte limit for `/run` and `/run-now` |
| `TIMEOUT_SCRIPT` | `30` | Script timeout in seconds; the effective deadline adds 5 seconds |
| `MAX_CPUS` | `1` | CPU cores for `hakorun.slice`, written as `CPUQuota = N × 100%` (Linux only) |
| `MAX_MEMORY` | `128M` | `MemoryMax` of `hakorun.slice` in systemd units (Linux only) |

## Redis (`-tags redis` only)

| Variable | Default | Description |
|----------|---------|-------------|
| `REDIS_HOST` | `localhost` | Host |
| `REDIS_PORT` | `6379` | Port |
| `REDIS_PASSWORD` | empty | Password |
| `REDIS_DB` | `0` | Database index |
| `REDIS_TIMEOUT_SECONDS` | `5` | Dial, read, write, and pool timeout in seconds |

The default ToriiDB build reads no `REDIS_*` variables.

## Related Pages

- [Resource Limits](/resource-limits)
- [Storage](/storage)
