Move child spec into proto_sup

This commit is contained in:
Camden Dixie O'Brien 2025-02-25 15:57:12 +00:00
parent 4eceba338c
commit 538405fec9
2 changed files with 7 additions and 10 deletions

View File

@ -14,5 +14,10 @@ init([Port, CertDir]) ->
SupFlags = #{stragegy => one_for_all,
intensity => 1,
period => 5},
ChildSpecs = [tcp_server:child_spec(Port, CertDir)],
ChildSpecs = [#{id => tcp_server,
start => {tcp_server, start_link, [Port, CertDir]},
restart => permanent,
shutdown => 5000,
type => worker,
modules => [tcp_server]}],
{ok, {SupFlags, ChildSpecs}}.

View File

@ -4,7 +4,7 @@
-module(tcp_server).
-behaviour(gen_server).
-export([start_link/2, child_spec/2]).
-export([start_link/2]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@ -13,14 +13,6 @@
start_link(Port, CertDir) ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [Port, CertDir], []).
child_spec(Port, CertDir) ->
#{id => ?MODULE,
start => {?MODULE, start_link, [Port, CertDir]},
restart => permanent,
shutdown => 5000,
type => worker,
modules => [?MODULE]}.
init([Port, CertDir]) ->
SslOpts = [{certfile, filename:join([CertDir, "server.pem"])},
{cacertfile, filename:join([CertDir, "ca.pem"])},