Ensured some dynamic RR config for prod env, based on env vars

This commit is contained in:
Alejandro Celaya 2022-08-27 17:17:37 +02:00
parent 2099ea16ec
commit 8852739111
6 changed files with 18 additions and 23 deletions

View file

@ -47,7 +47,7 @@ jobs:
php-version: ${{ matrix.php-version }}
tools: composer
- run: composer install --no-interaction --prefer-dist
- run: ./vendor/bin/rr get --location bin/ && chmod +x bin/rr
- run: ./vendor/bin/rr get --no-interaction --location bin/ && chmod +x bin/rr
- run: composer test:api:rr
cli-tests:

View file

@ -60,7 +60,7 @@ LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
COPY --from=builder /etc/shlink .
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink && \
if [ "$SHLINK_RUNTIME" == 'rr' ]; then \
php ./vendor/bin/rr get --location bin/ && chmod +x bin/rr ; \
php ./vendor/bin/rr get --no-interaction --location bin/ && chmod +x bin/rr ; \
fi;
# Expose default port

View file

@ -9,19 +9,14 @@ server:
http:
address: '0.0.0.0:8080'
static:
dir: ../../public
forbid:
- .php
- .htaccess
dir: '../../public'
forbid: ['.php', '.htaccess']
pool:
num_workers: 3
supervisor:
max_worker_memory: 100
num_workers: 16
jobs:
pool:
num_workers: 2
max_worker_memory: 100
num_workers: 16
timeout: 300
consume: ['shlink']
pipelines:

View file

@ -7,22 +7,17 @@ server:
command: 'php -dopcache.enable_cli=1 -dopcache.validate_timestamps=0 ../../bin/roadrunner-worker.php'
http:
address: '0.0.0.0:8080'
address: '0.0.0.0:${PORT}'
static:
dir: ../../public
forbid:
- .php
- .htaccess
dir: '../../public'
forbid: ['.php', '.htaccess']
pool:
num_workers: 16 # TODO Make configurable
supervisor:
max_worker_memory: 100
num_workers: ${WEB_WORKER_NUM}
jobs:
timeout: 300
timeout: 300 # 5 minutes
pool:
num_workers: 16 # TODO Make configurable
max_worker_memory: 100
num_workers: ${TASK_WORKER_NUM}
consume: ['shlink']
pipelines:
shlink:

View file

@ -68,6 +68,6 @@ CMD \
# Install dependencies if the vendor dir does not exist
if [[ ! -d "./vendor" ]]; then /usr/local/bin/composer install ; fi && \
# Download roadrunner binary
if [[ ! -f "./bin/rr" ]]; then ./vendor/bin/rr get --location bin/ && chmod +x bin/rr ; fi && \
if [[ ! -f "./bin/rr" ]]; then ./vendor/bin/rr get --no-interaction --location bin/ && chmod +x bin/rr ; fi && \
# This forces the app to be started every second until the exit code is 0
until ./bin/rr serve -c config/roadrunner/.rr.dev.yml; do sleep 1 ; done

View file

@ -31,6 +31,11 @@ if [ $ENABLE_PERIODIC_VISIT_LOCATE ]; then
/usr/sbin/crond &
fi
# RoadRunner config needs these to have been set, so falling back to default values if not set yet
export PORT="${PORT:-"8765"}"
export WEB_WORKER_NUM="${WEB_WORKER_NUM:-"16"}"
export TASK_WORKER_NUM="${TASK_WORKER_NUM:-"16"}"
if [ "$SHLINK_RUNTIME" == 'openswoole' ]; then
# When restarting the container, openswoole might think it is already in execution
# This forces the app to be started every second until the exit code is 0