From a6e0c34abe60bea9a15cc417a48d4953365151ef Mon Sep 17 00:00:00 2001 From: mithereal Date: Sat, 30 Jul 2022 16:35:47 -0700 Subject: [PATCH] refactor --- app.json | 4 ---- config/config.exs | 3 +-- config/runtime.exs | 5 +++-- heroku.yml | 3 +-- lib/farside/application.ex | 6 +++++- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app.json b/app.json index c41be98..20a6559 100644 --- a/app.json +++ b/app.json @@ -6,10 +6,6 @@ "keywords": ["elixir", "farside" ], "env": { "MIX_ENV": "prod", - "FARSIDE_PORT": { - "description": "The Port Farside is running on", - "value": "443" - }, "FARSIDE_SERVICES_JSON": { "description": "The json of services available", "value": "", diff --git a/config/config.exs b/config/config.exs index 1324272..eaabb0d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -14,5 +14,4 @@ config :farside, queries: [ "weather", "time" - ], - services_json_data: System.get_env("FARSIDE_SERVICES_JSON") || "" + ] diff --git a/config/runtime.exs b/config/runtime.exs index 1fce4a3..632a3cc 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,5 +1,6 @@ import Config config :farside, - port: System.get_env("FARSIDE_PORT", "4001"), - services_json: System.get_env("FARSIDE_SERVICES_JSON", "services.json") + port: System.get_env("FARSIDE_PORT", nil), + services_json: System.get_env("FARSIDE_SERVICES_JSON", "services.json"), + services_json_data: System.get_env("FARSIDE_SERVICES_JSON_DATA") || "" diff --git a/heroku.yml b/heroku.yml index aa12458..3ca98a7 100644 --- a/heroku.yml +++ b/heroku.yml @@ -6,5 +6,4 @@ build: web: exec /opt/app/bin/server start config: MIX_ENV: prod - FARSIDE_PORT: $FARSIDE_PORT - FARSIDE_SERVICES_JSON: $FARSIDE_SERVICES_JSON \ No newline at end of file + FARSIDE_SERVICES_JSON_DATA: $FARSIDE_SERVICES_JSON_DATA \ No newline at end of file diff --git a/lib/farside/application.ex b/lib/farside/application.ex index dbeb0ce..b22ccbc 100644 --- a/lib/farside/application.ex +++ b/lib/farside/application.ex @@ -11,7 +11,11 @@ defmodule Farside.Application do @impl true def start(_type, _args) do - port = Application.fetch_env!(:farside, :port) + port = + case Application.fetch_env!(:farside, :port) do + nil -> System.get_env("PORT") + port -> port + end Logger.info("Running on http://localhost:#{port}")