Skip to content

Commit

Permalink
Add support to read config from environment variable
Browse files Browse the repository at this point in the history
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 #1015 et al.
  • Loading branch information
leonklingele committed Feb 4, 2020
1 parent 9841f74 commit e3c10d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/invidious.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e3c10d7

Please sign in to comment.