Skip to content

Commit 8c081f2

Browse files
authored
update envrc template and improve local dev tooling (#971)
1 parent 1e3f680 commit 8c081f2

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

.envrc.template

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ export API_V3_URL=https://api-dev-green.mbtace.com
1717
#export CHELSEA_BRIDGE_USERNAME=
1818
#export CHELSEA_BRIDGE_PASSWORD=
1919

20+
# URL and access key for Watts. Required. The staging key can be found in the shared 1Password vault,
21+
# in the "Watts Staging API key" entry.
22+
export WATTS_URL=https://watts-staging.mbtace.com
23+
#export WATTS_API_KEY=
24+
25+
# URL and access key for Screenplay. Required. API keys can be found in the shared 1Password vault,
26+
# search for "Screenplay"
27+
export SCREENPLAY_BASE_URL=https://screenplay-dev.mbtace.com
28+
#export SCREENPLAY_API_KEY=
29+
30+
# Mapping of SCU names to hosts. Optional. Leave unset to skip sending messages to Scully, or uncomment
31+
# to use a locally running instance.
32+
#export SCU_IP_MAP="{\"*\": \"localhost:4010\"}"
33+
#export SCULLY_API_KEY=
34+
2035
# URLs of the enhanced trip-update and vehicle-position feeds.
2136
#export TRIP_UPDATE_URL="https://s3.amazonaws.com/mbta-gtfs-s3/concentrate/TripUpdates_enhanced.json"
2237
#export VEHICLE_POSITIONS_URL="https://s3.amazonaws.com/mbta-gtfs-s3/concentrate/VehiclePositions_enhanced.json"
38+
39+
# Comma seprated list of sign ids to run for debugging purposes. If specified, these signs processes
40+
# will be run in isolation to reduce log noise.
41+
#export ONLY_SIGN_IDS=lab_test_1

config/runtime.exs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if config_env() != :test do
2626
scully_api_key: System.get_env("SCULLY_API_KEY"),
2727
watts_url: System.get_env("WATTS_URL"),
2828
watts_api_key: System.get_env("WATTS_API_KEY"),
29-
scu_ip_map: System.get_env("SCU_IP_MAP", "null") |> Jason.decode!(),
29+
scu_ip_map: System.get_env("SCU_IP_MAP", "{}") |> Jason.decode!(),
3030
chelsea_bridge_password: System.get_env("CHELSEA_BRIDGE_PASSWORD"),
3131
chelsea_bridge_username: System.get_env("CHELSEA_BRIDGE_USERNAME"),
3232
number_of_http_updaters:
@@ -43,7 +43,12 @@ end
4343

4444
if config_env() == :dev do
4545
config :realtime_signs,
46-
sign_config_file: System.get_env("SIGN_CONFIG_FILE")
46+
sign_config_file: System.get_env("SIGN_CONFIG_FILE"),
47+
only_sign_ids:
48+
(case System.get_env("ONLY_SIGN_IDS") do
49+
nil -> nil
50+
string -> String.split(string, ",")
51+
end)
4752
end
4853

4954
message_log_job =

lib/pa_ess/scu_updater.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ defmodule PaEss.ScuUpdater do
3939
scu_ip_map = Application.get_env(:realtime_signs, :scu_ip_map)
4040
scully_api_key = Application.get_env(:realtime_signs, :scully_api_key)
4141

42-
if scu_ip_map do
42+
address = scu_ip_map[scu_id] || scu_ip_map["*"]
43+
44+
if address do
4345
http_poster.post(
44-
"http://#{Map.fetch!(scu_ip_map, scu_id)}#{path}",
46+
"http://#{address}#{path}",
4547
body,
4648
[{"Content-type", "application/json"}, {"x-api-key", scully_api_key}],
4749
hackney: [pool: :arinc_pool]

lib/signs/supervisor.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ defmodule Signs.Supervisor do
88

99
@impl true
1010
def init(_init_arg) do
11-
for sign_config <- Signs.Utilities.SignsConfig.children_config() do
11+
only_sign_ids = Application.get_env(:realtime_signs, :only_sign_ids)
12+
13+
for sign_config <- Signs.Utilities.SignsConfig.children_config(),
14+
!only_sign_ids or sign_config["id"] in only_sign_ids do
1215
sign_module =
1316
case sign_config do
1417
%{"type" => "realtime"} -> Signs.Realtime

0 commit comments

Comments
 (0)