Scott Hiett commited on
Commit
91ddbef
2 Parent(s): 289c675 662b76e

Merge pull request #22 from hiett/21-make-port-configurable

Browse files
Files changed (2) hide show
  1. .github/workflows/test.yml +2 -2
  2. lib/srh.ex +5 -3
.github/workflows/test.yml CHANGED
@@ -37,7 +37,7 @@ jobs:
37
  needs: build
38
  services:
39
  redis:
40
- image: redis/redis-stack-server:6.2.6-v6 # 6.2 is the Upstash compatible Redis version
41
 
42
  steps:
43
  - name: Checkout code
@@ -79,7 +79,7 @@ jobs:
79
  run: bun install
80
 
81
  - name: Run @upstash/redis Test Suite
82
- run: bun test pkg
83
  env:
84
  UPSTASH_REDIS_REST_URL: http://localhost:8080
85
  UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}
 
37
  needs: build
38
  services:
39
  redis:
40
+ image: redis/redis-stack-server:7.2.0-v7
41
 
42
  steps:
43
  - name: Checkout code
 
79
  run: bun install
80
 
81
  - name: Run @upstash/redis Test Suite
82
+ run: bun run test
83
  env:
84
  UPSTASH_REDIS_REST_URL: http://localhost:8080
85
  UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}
lib/srh.ex CHANGED
@@ -1,10 +1,12 @@
1
  defmodule Srh do
2
  use Application
3
 
4
- @port Application.fetch_env!(:srh, :port)
5
 
6
  def start(_type, _args) do
7
- IO.puts("Using port #{@port}")
 
 
8
 
9
  children = [
10
  Srh.Auth.TokenResolver,
@@ -14,7 +16,7 @@ defmodule Srh do
14
  scheme: :http,
15
  plug: Srh.Http.BaseRouter,
16
  options: [
17
- port: @port
18
  ]
19
  }
20
  ]
 
1
  defmodule Srh do
2
  use Application
3
 
4
+ @default_port Application.fetch_env!(:srh, :port)
5
 
6
  def start(_type, _args) do
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}")
10
 
11
  children = [
12
  Srh.Auth.TokenResolver,
 
16
  scheme: :http,
17
  plug: Srh.Http.BaseRouter,
18
  options: [
19
+ port: port
20
  ]
21
  }
22
  ]