<commit_before>-module(heimdall_sup).

-behaviour(supervisor).

%% External exports
-export([
         start_link/0,
         upgrade/0
        ]).

%% supervisor callbacks
-export([
         init/1
        ]).

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

%% NOTE: This is the same as found in chef_wm_sup
upgrade() ->
    {ok, {_, Specs}} = init([]),

    Old = sets:from_list(
            [Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]),
    New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]),
    Kill = sets:subtract(Old, New),

    sets:fold(fun (Id, ok) ->
                      %%% We wish to continue even if a child isn't found.
                      _ = supervisor:terminate_child(?MODULE, Id),
                      _ = supervisor:delete_child(?MODULE, Id),
                      ok
              end, ok, Kill),

    [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
    ok.

init([]) ->

    {ok, Ip} = application:get_env(heimdall, ip),
    {ok, Port} = application:get_env(heimdall, port),
    {ok, Dispatch} = file:consult(filename:join([code:priv_dir(heimdall),
                                                 "dispatch.conf"])),

    WebConfig = [
                 {ip, Ip},
                 {port, Port},
                 {log_dir, "priv/log"},
                 {dispatch, add_dynamic_config(Dispatch)}
                ],

    Web = {webmachine_mochiweb,<commit_msg>Enabled TCP no delay to improve request latency.<commit_after>-module(heimdall_sup).

-behaviour(supervisor).

%% External exports
-export([
         start_link/0,
         upgrade/0
        ]).

%% supervisor callbacks
-export([
         init/1
        ]).

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

%% NOTE: This is the same as found in chef_wm_sup
upgrade() ->
    {ok, {_, Specs}} = init([]),

    Old = sets:from_list(
            [Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]),
    New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]),
    Kill = sets:subtract(Old, New),

    sets:fold(fun (Id, ok) ->
                      %%% We wish to continue even if a child isn't found.
                      _ = supervisor:terminate_child(?MODULE, Id),
                      _ = supervisor:delete_child(?MODULE, Id),
                      ok
              end, ok, Kill),

    [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
    ok.

init([]) ->

    {ok, Ip} = application:get_env(heimdall, ip),
    {ok, Port} = application:get_env(heimdall, port),
    {ok, Dispatch} = file:consult(filename:join([code:priv_dir(heimdall),
                                                 "dispatch.conf"])),

    WebConfig = [
                 {ip, Ip},
                 {port, Port},
                 {log_dir, "priv/log"},
                 {dispatch, add_dynamic_config(Dispatch)},
                 {nodelay, true} % TCP 'no delay' for latency
                ],

    Web = {webmachine_mochiweb,
{'fraction_non_alphanumeric': 0.15236194278110446, 'fraction_numerical': 0.001996007984031936, 'mean_word_length': 1.8692748091603053, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3848510', 'n_tokens_mistral': 957, 'n_tokens_neox': 898, 'n_words': 193}