1
0
Fork 0
mirror of synced 2024-05-10 15:52:31 +12:00

Updated storage limit var

This commit is contained in:
Eldad Fux 2020-07-19 18:17:57 +03:00
parent a980770621
commit e4ff592eac
11 changed files with 47 additions and 19 deletions

1
.env
View file

@ -18,5 +18,6 @@ _APP_STATSD_HOST=telegraf
_APP_STATSD_PORT=8125
_APP_SMTP_HOST=maildev
_APP_SMTP_PORT=25
_APP_STORAGE_LIMIT=100000000
_APP_FUNCTIONS_TIMEOUT=900
_APP_FUNCTIONS_CONTAINERS=10

View file

@ -20,6 +20,7 @@
- Optimised function execution by using fully-qualified function calls
- Added support for boolean 'true' and 'false' in query strings alongside 1 and 0
- Added pagination for projects list on the console home page.
- Updated storage calculation to match IEC standards
- New and consistent response format for all API object + new response examples in the docs
- Removed user roles attribute from user object (can be fetched from /v1/teams/memberships) **
- Removed type attribute from session object response (used only internally)

View file

@ -77,7 +77,7 @@ ENV TZ=Asia/Tel_Aviv \
_APP_OPTIONS_ABUSE=enabled \
_APP_OPTIONS_FORCE_HTTPS=disabled \
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=104857600 \
_APP_STORAGE_LIMIT=100000000 \
_APP_STORAGE_ANTIVIRUS=enabled \
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \

View file

@ -77,7 +77,7 @@ ENV TZ=Asia/Tel_Aviv \
_APP_OPTIONS_ABUSE=enabled \
_APP_OPTIONS_FORCE_HTTPS=disabled \
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=104857600 \
_APP_STORAGE_LIMIT=100000000 \
_APP_STORAGE_ANTIVIRUS=enabled \
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \

View file

@ -60,7 +60,7 @@ ENV TZ=Asia/Tel_Aviv \
_APP_OPTIONS_ABUSE=enabled \
_APP_OPTIONS_FORCE_HTTPS=disabled \
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=104857600 \
_APP_STORAGE_LIMIT=100000000 \
_APP_STORAGE_ANTIVIRUS=enabled \
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \

View file

@ -77,7 +77,7 @@ ENV TZ=Asia/Tel_Aviv \
_APP_OPTIONS_ABUSE=enabled \
_APP_OPTIONS_FORCE_HTTPS=disabled \
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=104857600 \
_APP_STORAGE_LIMIT=100000000 \
_APP_STORAGE_ANTIVIRUS=enabled \
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \

View file

@ -77,7 +77,7 @@ ENV TZ=Asia/Tel_Aviv \
_APP_OPTIONS_ABUSE=enabled \
_APP_OPTIONS_FORCE_HTTPS=disabled \
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=104857600 \
_APP_STORAGE_LIMIT=100000000 \
_APP_STORAGE_ANTIVIRUS=enabled \
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \

View file

@ -23,6 +23,8 @@ sleep(2);
$http = new Server("0.0.0.0", 80);
$payloadSize = max(4000000 /* 4mb */, App::getEnv('_APP_STORAGE_LIMIT', 100000000));
$http
->set([
'open_http2_protocol' => true,
@ -31,7 +33,7 @@ $http
'timeout' => 7,
'http_compression' => true,
'http_compression_level' => 6,
'package_max_length' => 1000000 * 150, // 150MB
'package_max_length' => $payloadSize,
])
;
@ -47,8 +49,8 @@ $http->on('AfterReload', function($serv, $workerId) {
Console::success('Reload completed...');
});
$http->on('start', function (Server $http) {
Console::success('Server started succefully');
$http->on('start', function (Server $http) use ($payloadSize) {
Console::success('Server started succefully (max payload is '.$payloadSize.' bytes)');
Console::info("Master pid {$http->master_pid}, manager pid {$http->manager_pid}");

View file

@ -80,6 +80,7 @@ services:
- _APP_DB_PASS
- _APP_INFLUXDB_HOST
- _APP_INFLUXDB_PORT
- _APP_STORAGE_LIMIT
- _APP_FUNCTIONS_TIMEOUT
- _APP_FUNCTIONS_CONTAINERS

View file

@ -67,24 +67,45 @@ class Storage
/**
* Human readable data size format from bytes input.
*
* As published on https://gist.github.com/liunian/9338301 (first comment)
* Based on: https://stackoverflow.com/a/38659168/2299554
*
* @param int $bytes
* @param int $decimals
* @param string $system
*
* @return string
*/
public static function human($bytes, $decimals = 2)
public static function human(int $bytes, $decimals = 2, $system = 'metric')
{
$units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$step = 1024;
$i = 0;
$mod = ($system === 'binary') ? 1024 : 1000;
while (($bytes / $step) > 0.9) {
$bytes = $bytes / $step;
++$i;
}
$units = array(
'binary' => array(
'B',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB',
),
'metric' => array(
'B',
'kB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
),
);
return \round($bytes, $decimals).$units[$i];
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f%s", $bytes / pow($mod, $factor), $units[$system][$factor]);
}
}
}

View file

@ -12,6 +12,8 @@ class FileSize extends Validator
protected $max;
/**
* Max size in bytes
*
* @param int $max
*/
public function __construct($max)