Skip to content

Commit aecda2b

Browse files
authored
Merge pull request #264 from buggregator/feature/tcp-packet-size
feat: Add ENV variable support for buggregator server configuration
2 parents 5d76cf0 + 5762adb commit aecda2b

File tree

5 files changed

+58
-37
lines changed

5 files changed

+58
-37
lines changed

.docker/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ EXPOSE 8082/tcp
4646

4747
ENV APP_VERSION=$APP_VERSION
4848
ENV RR_LOG_LEVEL=error
49-
ENV RR_HTTP_NUM_WORKERS=2
50-
ENV RR_CENTRIFUGE_NUM_WORKERS=3
51-
ENV RR_HTTP_NUM_WORKERS=2
52-
ENV RR_TCP_NUM_WORKERS=2
5349
ENV RR_CENTRIFUGE_PROXY_ADDRESS="tcp://127.0.0.1:10001"
5450
ENV RR_CENTRIFUGE_GRPC_API_ADDRESS="127.0.0.1:10000"
5551

.rr-prod.yaml

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,67 @@ server:
1313
command: "php app.php register:modules"
1414

1515
logs:
16-
level: ${RR_LOG_LEVEL:-info}
16+
# Logging mode can be "development", "production" or "raw".
17+
# Do not forget to change this value for production environment.
18+
mode: ${RR_LOG_MODE:-production}
19+
# Encoding format can be "console" or "json" (last is preferred for production usage).
20+
encoding: ${RR_LOG_ENCODING:-json}
21+
# Logging level can be "panic", "error", "warn", "info", "debug".
22+
level: ${RR_LOG_LEVEL:-warn}
23+
channels:
24+
http:
25+
# HTTP plugin logging level can be "panic", "error", "warn", "info", "debug".
26+
level: ${RR_LOG_HTTP_LEVEL:-warn}
27+
tcp:
28+
# TCP plugin logging level can be "panic", "error", "warn", "info", "debug".
29+
level: ${RR_LOG_TCP_LEVEL:-warn}
30+
jobs:
31+
# JOBS plugin logging level can be "panic", "error", "warn", "info", "debug".
32+
level: ${RR_LOG_TCP_LEVEL:-warn}
33+
centrifuge:
34+
# Centrifuge plugin logging level can be "panic", "error", "warn", "info", "debug".
35+
level: ${RR_LOG_CENTRIFUGE_LEVEL:-warn}
36+
server:
37+
# Server logging level can be "panic", "error", "warn", "info", "debug".
38+
level: ${RR_LOG_SERVER_LEVEL:-warn}
39+
service:
40+
# Service logging level can be "panic", "error", "warn", "info", "debug".
41+
level: ${RR_LOG_SERVICE_LEVEL:-warn}
1742

1843
http:
1944
address: 127.0.0.1:8082
2045
middleware: [ "headers" ]
2146
headers:
2247
cors:
23-
allowed_origin: "*"
24-
allowed_headers: "*"
48+
allowed_origin: ${RR_HTTP_ALLOWED_ORIGIN:-*}
49+
allowed_headers: ${RR_HTTP_ALLOWED_HEADERS:-*}
2550
allowed_methods: "GET,POST,PUT,DELETE"
26-
allow_credentials: true
51+
allow_credentials: ${RR_HTTP_ALLOW_CREDENTIALS:-true}
2752
exposed_headers: "Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma"
2853
max_age: 600
2954
pool:
30-
num_workers: ${RR_HTTP_NUM_WORKERS}
55+
num_workers: ${RR_HTTP_NUM_WORKERS:-1}
3156

3257
tcp:
3358
servers:
3459
monolog:
35-
addr: :9913
60+
# Address to listen.
61+
addr: ${RR_TCP_MONOLOG_ADDR:-:9913}
3662
delimiter: "\n"
3763
var-dumper:
38-
addr: :9912
64+
# Address to listen.
65+
addr: ${RR_TCP_VAR_DUMPER_ADDR:-:9912}
3966
delimiter: "\n"
4067
smtp:
41-
addr: :1025
68+
# Address to listen.
69+
addr: ${RR_TCP_SMTP_ADDR:-:1025}
70+
# Chunks that RR uses to read the data. In bytes.
71+
# If you expect big payloads on a TCP server, to reduce `read` syscalls,
72+
# would be a good practice to use a fairly big enough buffer.
73+
# Default: 1024 * 1024 * 50 (50MB)
74+
read_buf_size: ${RR_TCP_READ_BUF_SIZE:-50485760}
4275
pool:
43-
num_workers: ${RR_TCP_NUM_WORKERS}
76+
num_workers: ${RR_TCP_NUM_WORKERS:-2}
4477

4578
kv:
4679
local:
@@ -49,26 +82,28 @@ kv:
4982

5083
jobs:
5184
consume: [ ]
85+
pool:
86+
num_workers: ${RR_JOBS_NUM_WORKERS:-1}
5287

5388
service:
5489
nginx:
5590
service_name_in_log: true
5691
remain_after_exit: true
57-
restart_sec: 1
92+
restart_sec: 5
5893
command: "/usr/sbin/nginx"
5994
centrifuge:
6095
service_name_in_log: true
6196
remain_after_exit: true
62-
restart_sec: 1
97+
restart_sec: 5
6398
command: "./bin/centrifugo --config=centrifugo.json"
6499
dolt:
65100
service_name_in_log: true
66101
remain_after_exit: true
67-
restart_sec: 1
102+
restart_sec: 5
68103
command: "./bin/dolt sql-server --data-dir=.db"
69104

70105
centrifuge:
71106
proxy_address: ${RR_CENTRIFUGE_PROXY_ADDRESS}
72107
grpc_api_address: ${RR_CENTRIFUGE_GRPC_API_ADDRESS}
73108
poll:
74-
num_workers: ${RR_CENTRIFUGE_NUM_WORKERS}
109+
num_workers: ${RR_CENTRIFUGE_NUM_WORKERS:-2}

.rr.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ http:
2727
exposed_headers: "Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma"
2828
max_age: 600
2929
pool:
30-
num_workers: 2
30+
num_workers: 1
3131

3232
tcp:
3333
servers:
@@ -39,6 +39,8 @@ tcp:
3939
delimiter: "\n"
4040
smtp:
4141
addr: 127.0.0.1:1025
42+
pool:
43+
num_workers: 2
4244

4345
kv:
4446
local:
@@ -47,22 +49,24 @@ kv:
4749

4850
jobs:
4951
consume: [ ]
52+
pool:
53+
num_workers: 1
5054

5155
service:
5256
centrifuge:
5357
service_name_in_log: true
5458
remain_after_exit: true
55-
restart_sec: 1
59+
restart_sec: 5
5660
command: "./bin/centrifugo --config=centrifugo.json"
5761
dolt:
5862
service_name_in_log: true
5963
remain_after_exit: true
60-
restart_sec: 1
64+
restart_sec: 5
6165
command: "./bin/dolt sql-server --data-dir=.db"
6266

6367
centrifuge:
6468
proxy_address: "tcp://127.0.0.1:10001"
6569
grpc_api_address: "tcp://127.0.0.1:10000"
6670
pool:
6771
reset_timeout: 10
68-
num_workers: 5
72+
num_workers: 2

app/config/database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
),
5656

5757
// Only for testing purposes
58-
// SQLite does not support multiple connections in the same time
58+
// SQLite does not support multiple connections simultaneously
5959
'sqlite' => new SQLiteDriverConfig(
6060
connection: new FileConnectionConfig(database: directory('runtime') . 'test.db'),
6161
options: [

docker-compose.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ services:
4040
DB_DRIVER: pgsql
4141
DB_HOST: buggregator-pgsql
4242

43-
# PERSISTENCE_DRIVER: mongodb
44-
MONGODB_CONNECTION: mongodb://homestead:secret@buggregator-mongo:27017
45-
MONGODB_DATABASE: buggregator
46-
4743
# Auth
4844
AUTH_ENABLED: false
4945
AUTH_PROVIDER_URL: https://${AUTH_DOMAIN}.us.auth0.com
@@ -63,17 +59,7 @@ services:
6359
- ./app:/app/app
6460
- ./runtime:/app/runtime
6561
- ./vendor:/app/vendor
66-
networks:
67-
- buggregator-network
68-
69-
buggregator-mongo:
70-
image: mongo:latest
71-
environment:
72-
MONGO_INITDB_ROOT_USERNAME: homestead
73-
MONGO_INITDB_ROOT_PASSWORD: secret
74-
MONGO_INITDB_DATABASE: buggregator
75-
ports:
76-
- 27017:27017
62+
- ./.rr-prod.yaml:/app/.rr-prod.yaml
7763
networks:
7864
- buggregator-network
7965

0 commit comments

Comments
 (0)