We’ve come up with a not-so-great workaround for now.
SocketDrano had a couple issues for us:
- it relied on channel join telemetry events, so it would miss sockets that do not join a channel
- it was oriented around draining upon sigterm, but we’re relying on CodeDeploy lifecycle events for triggering the draining
So, we ended up “extending” Phoenix.Socket by creating our own Socket module that has overrideable callbacks:
Then we create a custom init callback:
@impl Phoenix.Socket.Transport
def init(state) do
super(state)
|> tap(fn
{:ok, {_state, %Phoenix.Socket{transport_pid: pid}}} when is_pid(pid) ->
track_socket(pid)
_ ->
:ok
end)
end
track_socket then does essentially what SocketDrano does (monitor the socket pids, disconnects them when told to).
I’ve opened a thread on the Phoenix Core mailing list asking about better solutions being added Phoenix itself: https://groups.google.com/g/phoenix-core/c/1umhh2X1oAM/m/_sfxU8xIBgAJ






















