Download src/hk_browser_session_sup.erl from Snapkitty/hyperkitty-chromium: direct link, hf CLI and curl.
- Browser
- Download file 2.12 kB
-
https://huggingface.co/Snapkitty/hyperkitty-chromium/resolve/main/src/hk_browser_session_sup.erl
- Command line
-
hf download hf://Snapkitty/hyperkitty-chromium/src/hk_browser_session_sup.erl
-
curl -L -o hk_browser_session_sup.erl https://huggingface.co/Snapkitty/hyperkitty-chromium/resolve/main/src/hk_browser_session_sup.erl
2.12 kB
| % SPDX-License-Identifier: LicenseRef-Sovereign-Leviathan-SL-AGPL3-001 | |
| % Licensing: see LICENSE in the repository root. | |
| %%%------------------------------------------------------------------- | |
| %%% @doc HK-BROWSER :: supervises one `hk_browser_session' child per | |
| %%% active session. | |
| %%% | |
| %%% Sessions are `simple_one_for_one', `transient': a session that | |
| %%% terminates normally (an explicit `close_session') is not | |
| %%% restarted, but a session whose Chromium process crashed | |
| %%% (`hk_browser_session' stops with an abnormal reason, see its | |
| %%% `handle_info' clause for `exit_status') *is* restarted with the | |
| %%% same start arguments -- a fresh Chromium process comes up under | |
| %%% the same `session_id'. This is the concrete demonstration the | |
| %%% spec asks for: one browser session crashing never takes down | |
| %%% `hk_agent_sup', `hk_search_sup', or any other session -- and, | |
| %%% because this pool is its own supervisor nested under | |
| %%% `hk_browser_sup' rather than sharing a supervisor with the | |
| %%% session registry, restart storms in the session pool cannot | |
| %%% (via `hk_browser_sup''s own intensity/period) take the registry | |
| %%% down with them either. | |
| %%% @end | |
| %%%------------------------------------------------------------------- | |
| -module(hk_browser_session_sup). | |
| -behaviour(supervisor). | |
| -export([start_link/0, init/1, start_session/1]). | |
| start_link() -> | |
| hk_sup_util:start_link_retry( | |
| fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []) end). | |
| %% @doc Start a new supervised browser session. `Args' is the map | |
| %% `hk_browser_session:init/1' expects (`session_id', `owner_agent_id', | |
| %% `profile'). | |
| -spec start_session(map()) -> {ok, pid()} | {error, term()}. | |
| start_session(Args) -> | |
| supervisor:start_child(?MODULE, [Args]). | |
| init([]) -> | |
| SupFlags = #{strategy => simple_one_for_one, intensity => 10, period => 60}, | |
| Children = [ | |
| #{id => hk_browser_session, | |
| start => {hk_browser_session, start_link, []}, | |
| restart => transient, | |
| shutdown => 10000, | |
| type => worker, | |
| modules => [hk_browser_session]} | |
| ], | |
| {ok, {SupFlags, Children}}. | |