Merge pull request 'Gopher: Fix crash on (re)boot when ConfigDB is enabled' (#7826) from fix-gopher-crash into develop
Reviewed-on: https://git.pleroma.social/pleroma/pleroma/pulls/7826
This commit is contained in:
commit
d95d7f6eba
2 changed files with 10 additions and 2 deletions
1
changelog.d/gopher-genserver-crash-on-boot.fix
Normal file
1
changelog.d/gopher-genserver-crash-on-boot.fix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Gopher: Fix Ranch listener not being stopped properly on Pleroma restart when database configuration is enabled
|
||||
|
|
@ -21,10 +21,13 @@ defmodule Pleroma.Gopher.Server do
|
|||
|
||||
def init([ip, port]) do
|
||||
Logger.info("Starting gopher server on #{port}")
|
||||
Process.flag(:trap_exit, true)
|
||||
|
||||
listener = :gopher
|
||||
|
||||
{:ok, _pid} =
|
||||
:ranch.start_listener(
|
||||
:gopher,
|
||||
listener,
|
||||
:ranch_tcp,
|
||||
%{
|
||||
num_acceptors: 100,
|
||||
|
|
@ -35,7 +38,11 @@ defmodule Pleroma.Gopher.Server do
|
|||
[]
|
||||
)
|
||||
|
||||
{:ok, %{ip: ip, port: port}}
|
||||
{:ok, %{ip: ip, port: port, listener: listener}}
|
||||
end
|
||||
|
||||
def terminate(_reason, state) do
|
||||
:ranch.stop_listener(state.listener)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue