diff --git a/gex_httpd/priv/index.html b/gex_httpd/priv/static/index.html similarity index 100% rename from gex_httpd/priv/index.html rename to gex_httpd/priv/static/index.html diff --git a/gex_httpd/src/gh_client_man.erl b/gex_httpd/src/gh_client_man.erl index c913dcc..cf0bcf0 100644 --- a/gex_httpd/src/gh_client_man.erl +++ b/gex_httpd/src/gh_client_man.erl @@ -206,7 +206,6 @@ terminate(_, _) -> do_listen(PortNum, State = #s{port_num = none}) -> SocketOptions = [inet6, - {packet, line}, {active, once}, {mode, binary}, {keepalive, true}, diff --git a/gex_httpd/src/gh_sfc.erl b/gex_httpd/src/gh_sfc.erl new file mode 100644 index 0000000..288bb6d --- /dev/null +++ b/gex_httpd/src/gh_sfc.erl @@ -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}. diff --git a/gex_httpd/src/gh_sup.erl b/gex_httpd/src/gh_sup.erl index 934d1c1..ca10a8b 100644 --- a/gex_httpd/src/gh_sup.erl +++ b/gex_httpd/src/gh_sup.erl @@ -15,7 +15,7 @@ -vsn("0.1.0"). -behaviour(supervisor). -author("Peter Harpending "). --copyright("Peter Harpending "). +-copyright("2025-2026 QPQ AG"). -export([start_link/0]). @@ -36,11 +36,17 @@ start_link() -> init([]) -> RestartStrategy = {one_for_one, 1, 60}, + StaticFileCache = {gh_sfc, + {gh_sfc, start_link, []}, + permanent, + 5000, + worker, + [gh_sfc]}, Clients = {gh_clients, {gh_clients, start_link, []}, permanent, 5000, supervisor, [gh_clients]}, - Children = [Clients], + Children = [StaticFileCache, Clients], {ok, {RestartStrategy, Children}}. diff --git a/gex_httpd/zomp.meta b/gex_httpd/zomp.meta index eb32a14..2c5d4b7 100644 --- a/gex_httpd/zomp.meta +++ b/gex_httpd/zomp.meta @@ -20,7 +20,7 @@ {key_name,none}. {a_email,"peterharpending@qpq.swiss"}. {c_email,"peterharpending@qpq.swiss"}. -{copyright,"Peter Harpending"}. +{copyright,"2025-2026, QPQ AG"}. {file_exts,[]}. {license,skip}. {repo_url,"https://git.qpq.swiss/QPQ-AG/gex"}.