Skip to content

Commit

Permalink
Fallback to JF_ env vars when FJ_ are missing in all cases (#199)
Browse files Browse the repository at this point in the history
* Fix parsing api token

* Fix other variables

* bump version
  • Loading branch information
roznawsk committed May 17, 2024
1 parent 7a311a4 commit 465ae81
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ip = ConfigReader.read_ip("FJ_IP") || Application.fetch_env!(:fishjam, :ip)
port = ConfigReader.read_port("FJ_PORT") || Application.fetch_env!(:fishjam, :port)

host =
case System.get_env("FJ_HOST") do
case ConfigReader.read_string("FJ_HOST") do
nil -> "#{:inet.ntoa(ip)}:#{port}"
other -> other
end
Expand All @@ -31,7 +31,7 @@ sip_used? = Fishjam.Component.SIP in components_used
config :fishjam,
jwt_max_age: 24 * 3600,
media_files_path:
System.get_env("FJ_RESOURCES_BASE_PATH", "fishjam_resources") |> Path.expand(),
ConfigReader.read_string("FJ_RESOURCES_BASE_PATH", "fishjam_resources") |> Path.expand(),
address: host,
metrics_ip: ConfigReader.read_ip("FJ_METRICS_IP") || {127, 0, 0, 1},
metrics_port: ConfigReader.read_port("FJ_METRICS_PORT") || 9568,
Expand All @@ -42,7 +42,7 @@ config :fishjam,
s3_config: ConfigReader.read_s3_config(),
git_commit: ConfigReader.read_git_commit()

case System.get_env("FJ_SERVER_API_TOKEN") do
case ConfigReader.read_string("FJ_SERVER_API_TOKEN") do
nil when prod? == true ->
raise """
environment variable FJ_SERVER_API_TOKEN is missing.
Expand All @@ -61,7 +61,7 @@ external_uri = URI.parse("//" <> host)

config :fishjam, FishjamWeb.Endpoint,
secret_key_base:
System.get_env("FJ_SECRET_KEY_BASE") || Base.encode64(:crypto.strong_rand_bytes(48)),
ConfigReader.read_string("FJ_SECRET_KEY_BASE") || Base.encode64(:crypto.strong_rand_bytes(48)),
url: [
host: external_uri.host,
port: external_uri.port || 443,
Expand Down
4 changes: 4 additions & 0 deletions lib/jellyfish/config_reader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ defmodule Fishjam.ConfigReader do
get_env("FJ_GIT_COMMIT", "dev")
end

def read_string(string, default \\ nil) do
get_env(string, default)
end

defp do_read_nodes_list_config(node_name_value, cookie, mode) do
nodes_value = get_env("FJ_DIST_NODES", "")

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Fishjam.MixProject do
def project do
[
app: :fishjam,
version: "0.6.0",
version: "0.6.1",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ info:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
title: Fishjam Media Server
version: 0.6.0
version: 0.6.1
openapi: 3.0.0
paths:
/health:
Expand Down

0 comments on commit 465ae81

Please sign in to comment.