Merge pull request #536 from acelaya-forks/feature/simplified-config-workers

Added workers nums handling to simplified config parser
This commit is contained in:
Alejandro Celaya 2019-11-10 12:11:41 +01:00 committed by GitHub
commit 94dc6f2053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -143,6 +143,8 @@ docker run \
-e "BASE_URL_REDIRECT_TO=https://my-landing-page.com" \ -e "BASE_URL_REDIRECT_TO=https://my-landing-page.com" \
-e "REDIS_SERVERS=tcp://172.20.0.1:6379,tcp://172.20.0.2:6379" \ -e "REDIS_SERVERS=tcp://172.20.0.1:6379,tcp://172.20.0.2:6379" \
-e "BASE_PATH=/my-campaign" \ -e "BASE_PATH=/my-campaign" \
-e WEB_WORKER_NUM=64 \
-e TASK_WORKER_NUM=32 \
shlinkio/shlink shlinkio/shlink
``` ```
@ -164,6 +166,9 @@ The whole configuration should have this format, but it can be split into multip
"invalid_short_url_redirect_to": "https://my-landing-page.com", "invalid_short_url_redirect_to": "https://my-landing-page.com",
"regular_404_redirect_to": "https://my-landing-page.com", "regular_404_redirect_to": "https://my-landing-page.com",
"base_url_redirect_to": "https://my-landing-page.com", "base_url_redirect_to": "https://my-landing-page.com",
"base_path": "/my-campaign",
"web_worker_num": 64,
"task_worker_num": 32,
"redis_servers": [ "redis_servers": [
"tcp://172.20.0.1:6379", "tcp://172.20.0.1:6379",
"tcp://172.20.0.2:6379" "tcp://172.20.0.2:6379"

View File

@ -30,6 +30,8 @@ class SimplifiedConfigParser
'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'], 'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'],
'redis_servers' => ['redis', 'servers'], 'redis_servers' => ['redis', 'servers'],
'base_path' => ['router', 'base_path'], 'base_path' => ['router', 'base_path'],
'web_worker_num' => ['zend-expressive-swoole', 'swoole-http-server', 'options', 'worker_num'],
'task_worker_num' => ['zend-expressive-swoole', 'swoole-http-server', 'options', 'task_worker_num'],
]; ];
private const SIMPLIFIED_CONFIG_SIDE_EFFECTS = [ private const SIMPLIFIED_CONFIG_SIDE_EFFECTS = [
'delete_short_url_threshold' => [ 'delete_short_url_threshold' => [

View File

@ -52,6 +52,7 @@ class SimplifiedConfigParserTest extends TestCase
'port' => '1234', 'port' => '1234',
], ],
'base_path' => '/foo/bar', 'base_path' => '/foo/bar',
'task_worker_num' => 50,
]; ];
$expected = [ $expected = [
'app_options' => [ 'app_options' => [
@ -102,6 +103,14 @@ class SimplifiedConfigParserTest extends TestCase
'not_found_redirects' => [ 'not_found_redirects' => [
'invalid_short_url' => 'foobar.com', 'invalid_short_url' => 'foobar.com',
], ],
'zend-expressive-swoole' => [
'swoole-http-server' => [
'options' => [
'task_worker_num' => 50,
],
],
],
]; ];
$result = ($this->postProcessor)(array_merge($config, $simplified)); $result = ($this->postProcessor)(array_merge($config, $simplified));