Allow memory_limit to be configurable

This commit is contained in:
Alejandro Celaya 2024-04-09 08:47:01 +02:00
parent 75f6f8dd18
commit 8a273e01e9
5 changed files with 5 additions and 2 deletions

View file

@ -31,6 +31,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
This allows for a better traceability, as the logs generated during those jobs will have a matching UUID as the logs generated during the request the triggered the job. This allows for a better traceability, as the logs generated during those jobs will have a matching UUID as the logs generated during the request the triggered the job.
* [#2087](https://github.com/shlinkio/shlink/issues/2087) Allow `memory_limit` to be configured via the new `MEMORY_LIMIT` env var.
### Deprecated ### Deprecated
* *Nothing* * *Nothing*

View file

@ -12,6 +12,8 @@ chdir(dirname(__DIR__));
require 'vendor/autoload.php'; require 'vendor/autoload.php';
// Set a default memory limit, but allow custom values
ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M'));
// This is one of the first files loaded. Configure the timezone here // This is one of the first files loaded. Configure the timezone here
date_default_timezone_set(EnvVars::TIMEZONE->loadFromEnv(date_default_timezone_get())); date_default_timezone_set(EnvVars::TIMEZONE->loadFromEnv(date_default_timezone_get()));

View file

@ -1,6 +1,5 @@
display_errors=On display_errors=On
error_reporting=-1 error_reporting=-1
memory_limit=-1
log_errors_max_len=0 log_errors_max_len=0
zend.assertions=1 zend.assertions=1
assert.exception=1 assert.exception=1

View file

@ -1,4 +1,3 @@
log_errors_max_len=0 log_errors_max_len=0
zend.assertions=1 zend.assertions=1
assert.exception=1 assert.exception=1
memory_limit=512M

View file

@ -71,6 +71,7 @@ enum EnvVars: string
case REDIRECT_APPEND_EXTRA_PATH = 'REDIRECT_APPEND_EXTRA_PATH'; case REDIRECT_APPEND_EXTRA_PATH = 'REDIRECT_APPEND_EXTRA_PATH';
case TIMEZONE = 'TIMEZONE'; case TIMEZONE = 'TIMEZONE';
case MULTI_SEGMENT_SLUGS_ENABLED = 'MULTI_SEGMENT_SLUGS_ENABLED'; case MULTI_SEGMENT_SLUGS_ENABLED = 'MULTI_SEGMENT_SLUGS_ENABLED';
case MEMORY_LIMIT = 'MEMORY_LIMIT';
public function loadFromEnv(mixed $default = null): mixed public function loadFromEnv(mixed $default = null): mixed
{ {