Skip to content

Commit f6a3955

Browse files
authored
Revise Yii configuration for RoadRunner setup (#385)
1 parent afc5758 commit f6a3955

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

‎src/guide/tutorial/using-yii-with-roadrunner.md‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,38 @@ First, we need to configure the server itself. Create `/.rr.yaml` and add the fo
2828
```yaml
2929
server:
3030
command: "php worker.php"
31+
env:
32+
YII_ENV: prod
33+
YII_DEBUG: false
3134

3235
rpc:
3336
listen: tcp://127.0.0.1:6001
3437

3538
http:
3639
address: :8080
3740
pool:
38-
num_workers: 4
39-
max_jobs: 64
40-
middleware: ["static", "headers"]
41+
debug: false # set to true for local development only
42+
supervisor:
43+
max_worker_memory: 192
44+
middleware: [static, gzip, headers, sendfile]
4145
static:
4246
dir: "public"
4347
forbid: [".php", ".htaccess"]
4448
headers:
4549
response:
4650
"Cache-Control": "no-cache"
4751

48-
reload:
49-
interval: 1s
50-
patterns: [ ".php" ]
51-
services:
52-
http:
53-
recursive: true
54-
dirs: [ "." ]
55-
5652
logs:
5753
mode: production
5854
level: warn
5955
```
6056
61-
We're specifying that entry script is `worker.php`, there should be three workers on port 8080, `public` directory
62-
files are static ones except `.php` and `.htaccess`. Also, we're sending an additional header.
57+
> [!INFO]
58+
> Read more about TLS, HTTP/2, HTTP/3 configuration and other middleware [on the RoadRunner docs](https://docs.roadrunner.dev/docs/http/http).
59+
60+
We're specifying that the entry script is `worker.php`, the server listens on port 8080, `public` directory
61+
files are served statically except `.php` and `.htaccess`. The `max_worker_memory` is a soft limit: if a worker
62+
exceeds 192 MB, it will restart after finishing its current request. Also, we're sending an additional header.
6363

6464
Create `/worker.php`:
6565

@@ -68,7 +68,6 @@ Create `/worker.php`:
6868
6969
declare(strict_types=1);
7070
71-
7271
use Yiisoft\Yii\Runner\RoadRunner\RoadRunnerApplicationRunner;
7372
7473
ini_set('display_errors', 'stderr');
@@ -83,7 +82,7 @@ require_once __DIR__ . '/preload.php';
8382
To start a server, execute the following command:
8483

8584
```
86-
./rr serve -d
85+
./rr serve
8786
```
8887

8988
## On worker scope

0 commit comments

Comments
 (0)