<commit_before>% Copyright (c) 2010, NorthScale, Inc.
% All rights reserved.

-module(ns_server).

-behavior(application).

-export([start_link/0, start/2, stop/1]).

start(_Type, _Args) ->
    start_link().

stop(_State) ->
    ok.

start_link() ->
    make_pidfile(),
    ping_jointo(),
    ns_server_sup:start_link().

% ----------------------------------

make_pidfile() ->
    case application:get_env(pidfile) of
        {ok, PidFile} -> make_pidfile(PidFile);
        X -> X
    end.

make_pidfile(PidFile) ->
    Pid = os:getpid(),
    ok = file:write_file(PidFile, list_to_binary(Pid)),
    ok.

ping_jointo() ->
    case application:get_env(jointo) of
        {ok, NodeName} -> ping_jointo(NodeName);
        X -> X
    end.

ping_jointo(NodeName) ->
    io:format("jointo: attempting to contact ~p~n", [NodeName]),
    case net_adm:ping(NodeName) of
        pong -> io:format("jointo: connected to ~p~n", [NodeName]);
        pang -> {error, io:format("jointo: could not ping ~p~n", [NodeName])}
    end.

<commit_msg>simple start/0 entry point for windows/NT-service<commit_after>% Copyright (c) 2010, NorthScale, Inc.
% All rights reserved.

-module(ns_server).

-behavior(application).

-export([start_link/0, start/2, start/0, stop/1]).

start() -> % Main entry point, mostly for windows/NT-service.
    application:start(ns_server).

start(_Type, _Args) ->
    start_link().

stop(_State) ->
    ok.

start_link() ->
    make_pidfile(),
    ping_jointo(),
    ns_server_sup:start_link().

% ----------------------------------

make_pidfile() ->
    case application:get_env(pidfile) of
        {ok, PidFile} -> make_pidfile(PidFile);
        X -> X
    end.

make_pidfile(PidFile) ->
    Pid = os:getpid(),
    ok = file:write_file(PidFile, list_to_binary(Pid)),
    ok.

ping_jointo() ->
    case application:get_env(jointo) of
        {ok, NodeName} -> ping_jointo(NodeName);
        X -> X
    end.

ping_jointo(NodeName) ->
    io:format("jointo: attempting to contact ~p~n", [NodeName]),
    case net_adm:ping(NodeName) of
        pong -> io:format("jointo: connected to ~p~n", [NodeName]);
        pang -> {error, io:format("jointo: could not ping ~p~n", [NodeName])}
    end.


{'fraction_non_alphanumeric': 0.18636363636363637, 'fraction_numerical': 0.007272727272727273, 'mean_word_length': 2.749574105621806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3902094', 'n_tokens_mistral': 804, 'n_tokens_neox': 786, 'n_words': 164}