From 18781367f58884b199a91ab8bf31b9ead2ef829b Mon Sep 17 00:00:00 2001 From: abdulmohsen Date: Tue, 12 Dec 2023 21:36:33 +0300 Subject: [PATCH] Expose http listen port as environment variable. --- Dockerfile | 2 ++ FAQ.md | 16 +++++----- bin/console | 9 ++++-- config/backend.spec.php | 47 ++++++++++++++++++----------- config/lang.php | 7 ----- container/files/Caddyfile | 4 +-- src/Commands/Config/EditCommand.php | 10 ++++-- src/Commands/Config/ViewCommand.php | 4 +-- 8 files changed, 60 insertions(+), 39 deletions(-) delete mode 100644 config/lang.php diff --git a/Dockerfile b/Dockerfile index b087fa31..3702b2f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,8 @@ ARG USER_ID=1000 ENV IN_CONTAINER=1 ENV PHP_INI_DIR=/etc/${PHP_V} ENV PATH=/opt/bin:${PATH} +ENV HTTP_PORT="8080" +ENV HTTPS_PORT="8443" # Setup the required environment. # diff --git a/FAQ.md b/FAQ.md index cdc14157..8e893e6e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -303,13 +303,14 @@ $ docker exec -ti watchstate console system:tasks #### Container specific environment variables. > [!IMPORTANT] -> These environment variables relates to the container itself, and must added via the `docker-compose.yaml` file. +> These environment variables relates to the container itself, and must be added via the `docker-compose.yaml` file. -| Key | Type | Description | Default | -|------------------|---------|------------------------------------|---------| -| WS_DISABLE_HTTP | integer | Disable included `HTTP Server`. | `0` | -| WS_DISABLE_CRON | integer | Disable included `Task Scheduler`. | `0` | -| WS_DISABLE_CACHE | integer | Disable included `Cache Server`. | `0` | +| Key | Type | Description | Default | +|------------------|---------|------------------------------------|----------| +| WS_DISABLE_HTTP | integer | Disable included `HTTP Server`. | `0` | +| WS_DISABLE_CRON | integer | Disable included `Task Scheduler`. | `0` | +| WS_DISABLE_CACHE | integer | Disable included `Cache Server`. | `0` | +| HTTP_PORT | string | Change the `HTTP` listen port. | `"8080"` | --- @@ -598,7 +599,8 @@ $ curl -v -H "Accept: application/json" -H "X-MediaBrowser-Token: [BACKEND_API_K ``` * Replace `[BACKEND_API_KEY]` with your jellyfin/emby api key. -* Replace `[BACKEND_HOST]` with your jellyfin/emby host. it can be a host or ip:port i.e. `jf.mydomain.ltd` or `172.23.0.11:8096` +* Replace `[BACKEND_HOST]` with your jellyfin/emby host. it can be a host or ip:port i.e. `jf.mydomain.ltd` + or `172.23.0.11:8096` ``` {"OperatingSystemDisplayName":"Linux","HasPendingRestart":false,"IsShuttingDown":false,...}} diff --git a/bin/console b/bin/console index 1e1d01ff..5addc4fd 100755 --- a/bin/console +++ b/bin/console @@ -54,9 +54,14 @@ require __DIR__ . '/../vendor/autoload.php'; try { $app = (new App\Libs\Initializer())->boot(); } catch (Throwable $e) { - $message = sprintf('%s: %s (%s:%d).', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()); + $message = sprintf( + 'Unhandled Exception [%s] was thrown. With message [%s] in [%s:%d].', + $e::class, + $e->getMessage(), + array_reverse(explode(ROOT_PATH, $e->getFile(), 2))[0], + $e->getLine() + ); fwrite(STDERR, trim($message) . PHP_EOL); - exit(503); } diff --git a/config/backend.spec.php b/config/backend.spec.php index 76b2dc6d..b4747158 100644 --- a/config/backend.spec.php +++ b/config/backend.spec.php @@ -1,21 +1,34 @@ true, + 'type' => true, + 'url' => true, + 'token' => true, + 'uuid' => true, + 'user' => true, + 'export.enabled' => true, + 'export.lastSync' => true, + 'import.enabled' => true, + 'import.lastSync' => true, + 'webhook.token' => true, + 'webhook.match.user' => true, + 'webhook.match.uuid' => true, + 'options.ignore' => true, + 'options.LIBRARY_SEGMENT' => true, + 'options.ADMIN_TOKEN' => false, + 'options.DUMP_PAYLOAD' => false, + 'options.DEBUG_TRACE' => false, + 'options.IMPORT_METADATA_ONLY' => false, + 'options.DRY_RUN' => false, + 'options.client.timeout' => false, ]; + diff --git a/config/lang.php b/config/lang.php deleted file mode 100644 index 9cd01d24..00000000 --- a/config/lang.php +++ /dev/null @@ -1,7 +0,0 @@ - '' . $val . '', - require __DIR__ . '/../../../config/backend.spec.php' - ) + array_keys( + array_filter( + array: require __DIR__ . '/../../../config/backend.spec.php', + callback: fn($val, $key) => $val, + mode: ARRAY_FILTER_USE_BOTH + ) + ) + ), ) ] ) diff --git a/src/Commands/Config/ViewCommand.php b/src/Commands/Config/ViewCommand.php index f6bfa8e2..448a7abe 100644 --- a/src/Commands/Config/ViewCommand.php +++ b/src/Commands/Config/ViewCommand.php @@ -158,8 +158,8 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti $suggest = []; - foreach (require __DIR__ . '/../../../config/backend.spec.php' as $name) { - if (empty($currentValue) || str_starts_with($name, $currentValue)) { + foreach (require __DIR__ . '/../../../config/backend.spec.php' as $name => $val) { + if (true === $val && (empty($currentValue) || str_starts_with($name, $currentValue))) { $suggest[] = $name; } }