Fix ETS table init, send failure handling, and deployment cleanup
- Initialize :aprsme ETS table in application.ex with message_number counter; was missing, causing crash in Is.send_message/1 - Trigger reconnect on gen_tcp.send failure instead of leaking the dead socket with active timers - Remove cluster-only env vars from deployment (POD_IP, POD_NAME, POD_NAMESPACE, RELEASE_DISTRIBUTION, RELEASE_NODE) since CLUSTER_ENABLED=false - Remove redundant APRS_PASSCODE secret ref now that APRS_PASSWORD is set as plaintext
This commit is contained in:
parent
224700361c
commit
6a0c8deb5e
3 changed files with 7 additions and 22 deletions
|
|
@ -108,22 +108,6 @@ spec:
|
||||||
- -c
|
- -c
|
||||||
- sleep 20
|
- sleep 20
|
||||||
env:
|
env:
|
||||||
- name: POD_IP
|
|
||||||
valueFrom:
|
|
||||||
fieldRef:
|
|
||||||
fieldPath: status.podIP
|
|
||||||
- name: POD_NAME
|
|
||||||
valueFrom:
|
|
||||||
fieldRef:
|
|
||||||
fieldPath: metadata.name
|
|
||||||
- name: POD_NAMESPACE
|
|
||||||
valueFrom:
|
|
||||||
fieldRef:
|
|
||||||
fieldPath: metadata.namespace
|
|
||||||
- name: RELEASE_DISTRIBUTION
|
|
||||||
value: "name"
|
|
||||||
- name: RELEASE_NODE
|
|
||||||
value: "aprsme@$(POD_IP)"
|
|
||||||
- name: CLUSTER_ENABLED
|
- name: CLUSTER_ENABLED
|
||||||
value: "false"
|
value: "false"
|
||||||
- name: PORT
|
- name: PORT
|
||||||
|
|
@ -154,11 +138,6 @@ spec:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: aprs-secrets
|
name: aprs-secrets
|
||||||
key: SECRET_KEY_BASE
|
key: SECRET_KEY_BASE
|
||||||
- name: APRS_PASSCODE
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: aprs-secrets
|
|
||||||
key: APRS_PASSCODE
|
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: aprs-db
|
name: aprs-db
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,8 @@ defmodule Aprsme.Application do
|
||||||
:ets.new(:query_cache, [:set, :public, :named_table, read_concurrency: true])
|
:ets.new(:query_cache, [:set, :public, :named_table, read_concurrency: true])
|
||||||
:ets.new(:device_cache, [:set, :public, :named_table, read_concurrency: true])
|
:ets.new(:device_cache, [:set, :public, :named_table, read_concurrency: true])
|
||||||
:ets.new(:symbol_cache, [:set, :public, :named_table, read_concurrency: true])
|
:ets.new(:symbol_cache, [:set, :public, :named_table, read_concurrency: true])
|
||||||
|
:ets.new(:aprsme, [:set, :public, :named_table, write_concurrency: true])
|
||||||
|
:ets.insert(:aprsme, {:message_number, 0})
|
||||||
|
|
||||||
[
|
[
|
||||||
# ETS-based rate limiter
|
# ETS-based rate limiter
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,11 @@ defmodule Aprsme.Is do
|
||||||
|
|
||||||
error ->
|
error ->
|
||||||
Logger.error("Failed to send message to APRS-IS: #{inspect(error)}")
|
Logger.error("Failed to send message to APRS-IS: #{inspect(error)}")
|
||||||
{:reply, {:error, error}, state}
|
if state.timer, do: Process.cancel_timer(state.timer)
|
||||||
|
if state.keepalive_timer, do: Process.cancel_timer(state.keepalive_timer)
|
||||||
|
:gen_tcp.close(socket)
|
||||||
|
schedule_reconnect(5000)
|
||||||
|
{:reply, {:error, error}, %{state | socket: nil, timer: nil, keepalive_timer: nil}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue