static file cache boots up
This commit is contained in:
parent
6ba256f016
commit
46b93158db
@ -206,7 +206,6 @@ terminate(_, _) ->
|
|||||||
do_listen(PortNum, State = #s{port_num = none}) ->
|
do_listen(PortNum, State = #s{port_num = none}) ->
|
||||||
SocketOptions =
|
SocketOptions =
|
||||||
[inet6,
|
[inet6,
|
||||||
{packet, line},
|
|
||||||
{active, once},
|
{active, once},
|
||||||
{mode, binary},
|
{mode, binary},
|
||||||
{keepalive, true},
|
{keepalive, true},
|
||||||
|
|||||||
91
gex_httpd/src/gh_sfc.erl
Normal file
91
gex_httpd/src/gh_sfc.erl
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
% @doc static file cache
|
||||||
|
%
|
||||||
|
% polls priv/static for sheeeit
|
||||||
|
-module(gh_sfc).
|
||||||
|
|
||||||
|
-behavior(gen_server).
|
||||||
|
|
||||||
|
-export_type([
|
||||||
|
]).
|
||||||
|
|
||||||
|
%% caller context: actual api
|
||||||
|
-export([
|
||||||
|
]).
|
||||||
|
|
||||||
|
%% caller context: startup
|
||||||
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
%% gen_server callbacks (process context)
|
||||||
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2]).
|
||||||
|
|
||||||
|
-include("$zx_include/zx_logger.hrl").
|
||||||
|
|
||||||
|
-record(s, {}).
|
||||||
|
-type state() :: #s{}.
|
||||||
|
|
||||||
|
|
||||||
|
%%------------------------------------------------------------------
|
||||||
|
%% API (ACTUAL API / CALLER CONTEXT)
|
||||||
|
%%------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%------------------------------------------------------------------
|
||||||
|
%% API (STARTUP / CALLER CONTEXT)
|
||||||
|
%%------------------------------------------------------------------
|
||||||
|
|
||||||
|
-spec start_link() -> {ok, pid()} | ignore | {error, term()}.
|
||||||
|
|
||||||
|
start_link() ->
|
||||||
|
gen_server:start_link({local, ?MODULE}, ?MODULE, none, []).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%------------------------------------------------------------------
|
||||||
|
%% API (GEN_SERVER CALLBACKS / PROCESS CONTEXT)
|
||||||
|
%%------------------------------------------------------------------
|
||||||
|
|
||||||
|
-spec init(Args) -> {ok, InitState}
|
||||||
|
when Args :: none,
|
||||||
|
InitState :: state().
|
||||||
|
|
||||||
|
init(none) ->
|
||||||
|
ok = tell("starting gh_sfc"),
|
||||||
|
{ok, #s{}}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-spec handle_call(Request, From, State) -> MaybeReply
|
||||||
|
when Request :: term(),
|
||||||
|
From :: {pid(), Tag :: term()},
|
||||||
|
State :: state(),
|
||||||
|
MaybeReply :: {reply, Reply, NewState}
|
||||||
|
| {noreply, NewState},
|
||||||
|
Reply :: term(),
|
||||||
|
NewState :: State.
|
||||||
|
|
||||||
|
handle_call(Unexpected, From, State) ->
|
||||||
|
ok = log(warning, "~p ~p: unexpected call from ~p: ~p", [?MODULE, self(), From, Unexpected]),
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-spec handle_cast(Request, State) -> {noreply, NewState}
|
||||||
|
when Request :: term(),
|
||||||
|
State :: state(),
|
||||||
|
NewState :: State.
|
||||||
|
|
||||||
|
handle_cast(Unexpected, State) ->
|
||||||
|
ok = log(warning, "~p ~p: unexpected cast: ~p", [?MODULE, self(), Unexpected]),
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-spec handle_info(Info, State) -> {noreply, NewState}
|
||||||
|
when Info :: term(),
|
||||||
|
State :: state(),
|
||||||
|
NewState :: State.
|
||||||
|
|
||||||
|
handle_info(Unexpected, State) ->
|
||||||
|
ok = log(warning, "~p ~p: unexpected info: ~p", [?MODULE, self(), Unexpected]),
|
||||||
|
{noreply, State}.
|
||||||
@ -15,7 +15,7 @@
|
|||||||
-vsn("0.1.0").
|
-vsn("0.1.0").
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
-copyright("2025-2026 QPQ AG").
|
||||||
|
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
@ -36,11 +36,17 @@ start_link() ->
|
|||||||
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
RestartStrategy = {one_for_one, 1, 60},
|
RestartStrategy = {one_for_one, 1, 60},
|
||||||
|
StaticFileCache = {gh_sfc,
|
||||||
|
{gh_sfc, start_link, []},
|
||||||
|
permanent,
|
||||||
|
5000,
|
||||||
|
worker,
|
||||||
|
[gh_sfc]},
|
||||||
Clients = {gh_clients,
|
Clients = {gh_clients,
|
||||||
{gh_clients, start_link, []},
|
{gh_clients, start_link, []},
|
||||||
permanent,
|
permanent,
|
||||||
5000,
|
5000,
|
||||||
supervisor,
|
supervisor,
|
||||||
[gh_clients]},
|
[gh_clients]},
|
||||||
Children = [Clients],
|
Children = [StaticFileCache, Clients],
|
||||||
{ok, {RestartStrategy, Children}}.
|
{ok, {RestartStrategy, Children}}.
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
{key_name,none}.
|
{key_name,none}.
|
||||||
{a_email,"peterharpending@qpq.swiss"}.
|
{a_email,"peterharpending@qpq.swiss"}.
|
||||||
{c_email,"peterharpending@qpq.swiss"}.
|
{c_email,"peterharpending@qpq.swiss"}.
|
||||||
{copyright,"Peter Harpending"}.
|
{copyright,"2025-2026, QPQ AG"}.
|
||||||
{file_exts,[]}.
|
{file_exts,[]}.
|
||||||
{license,skip}.
|
{license,skip}.
|
||||||
{repo_url,"https://git.qpq.swiss/QPQ-AG/gex"}.
|
{repo_url,"https://git.qpq.swiss/QPQ-AG/gex"}.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user