Skip to content

Commit 662b76e

Browse files
committed
Load port from env
1 parent 289c675 commit 662b76e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
needs: build
3838
services:
3939
redis:
40-
image: redis/redis-stack-server:6.2.6-v6 # 6.2 is the Upstash compatible Redis version
40+
image: redis/redis-stack-server:7.2.0-v7
4141

4242
steps:
4343
- name: Checkout code
@@ -79,7 +79,7 @@ jobs:
7979
run: bun install
8080

8181
- name: Run @upstash/redis Test Suite
82-
run: bun test pkg
82+
run: bun run test
8383
env:
8484
UPSTASH_REDIS_REST_URL: http://localhost:8080
8585
UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}

lib/srh.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
defmodule Srh do
22
use Application
33

4-
@port Application.fetch_env!(:srh, :port)
4+
@default_port Application.fetch_env!(:srh, :port)
55

66
def start(_type, _args) do
7-
IO.puts("Using port #{@port}")
7+
{port, ""} = Integer.parse(System.get_env("SRH_PORT", Integer.to_string(@default_port))) # Remains @default_port for backwards compatibility
8+
9+
IO.puts("Using port #{port}")
810

911
children = [
1012
Srh.Auth.TokenResolver,
@@ -14,7 +16,7 @@ defmodule Srh do
1416
scheme: :http,
1517
plug: Srh.Http.BaseRouter,
1618
options: [
17-
port: @port
19+
port: port
1820
]
1921
}
2022
]

0 commit comments

Comments
 (0)