diff options
| author | Leon Klingele <git@leonklingele.de> | 2020-02-04 15:50:28 +0100 |
|---|---|---|
| committer | Leon Klingele <git@leonklingele.de> | 2020-02-04 15:53:46 +0100 |
| commit | e3c10d779d315adc630e08005b6bdbdce32f7446 (patch) | |
| tree | 4e7ebbc1d7f8038b2d2c6292382b6222f4f0afa1 /src | |
| parent | 9841f74adc94a4845aea6aace8d2408c3255dfa7 (diff) | |
| download | invidious-e3c10d779d315adc630e08005b6bdbdce32f7446.tar.gz invidious-e3c10d779d315adc630e08005b6bdbdce32f7446.tar.bz2 invidious-e3c10d779d315adc630e08005b6bdbdce32f7446.zip | |
Add support to read config from environment variable
Try to read app config from the "INVIDIOUS_CONFIG" environment variable.
If the variable is undefined, read config from config.yml file as before.
Required by https://github.com/omarroth/invidious/pull/1015 et al.
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index f5fe4b3d..a4584d4b 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -28,8 +28,11 @@ require "protodec/utils" require "./invidious/helpers/*" require "./invidious/*" -CONFIG = Config.from_yaml(File.read("config/config.yml")) -HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32) +ENV_CONFIG_NAME = "INVIDIOUS_CONFIG" + +CONFIG_STR = ENV.has_key?(ENV_CONFIG_NAME) ? ENV.fetch(ENV_CONFIG_NAME) : File.read("config/config.yml") +CONFIG = Config.from_yaml(CONFIG_STR) +HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32) PG_URL = URI.new( scheme: "postgres", |
