<commit_before>;
; src/lfe/lib/dnsresolvd.lfe
; =============================================================================
; DNS Resolver Daemon (dnsresolvd). Version 0.1
; =============================================================================
; A daemon that performs DNS lookups for the given hostname
; passed in an HTTP request, with the focus on its implementation
; using various programming languages. (Cowboy-boosted impl.)
; =============================================================================
; Copyright (C) 2017-2018 <NAME>) Golubtsov
;
; (See the LICENSE file at the top of the source tree.)
;

(defmodule dnsresolvd
    "The main --application-- module of the daemon."

    (behaviour application)

    (export (start 2))
)

#|
 | @param args A list containing the server port number to listen on
 |             as the first element.
 |
 | @returns The tuple containing the PID of the top supervisor process
 |          and the state of the running application (or an empty list).
 |#
(defun start (_ args)
    "Starts up the daemon.
     It has to be the application module callback, but used directly
     from the startup script of the daemon."

    (let (((tuple port-number daemon-name log) args))

    (let (((tuple 'ok _) (: application ensure_all_started 'cowboy))))

    (let ((dispatch (: cowboy_router compile (list
        (tuple '_ (list
            (tuple "/" 'reqhandler ())
        ))
    ))))

    ; Starting up the plain HTTP listener on <port_number>.
    (let ((ret- (: cowboy start_clear 'http-listener (list (tuple
        'port port-number
    )) (map
        'env (map 'dispatch dispatch)
    ))))))

;   (: io put_chars (++ (: AUX MSG-SERVER-STARTED-1) (: AUX NEW-LINE)
;                       (: AUX MSG-SERVER-STARTED-2) (: AUX NEW-LINE)))
    )<commit_msg>cowboy/lfe: Print "Server started" notification message.<commit_after>;
; src/lfe/lib/dnsresolvd.lfe
; =============================================================================
; DNS Resolver Daemon (dnsresolvd). Version 0.1
; =============================================================================
; A daemon that performs DNS lookups for the given hostname
; passed in an HTTP request, with the focus on its implementation
; using various programming languages. (Cowboy-boosted impl.)
; =============================================================================
; Copyright (C) 2017-2018 Radislav (Radicchio) Golubtsov
;
; (See the LICENSE file at the top of the source tree.)
;

(defmodule dnsresolvd
    "The main --application-- module of the daemon."

    (behaviour application)

    (export (start 2))
)

#|
 | @param args A list containing the server port number to listen on
 |             as the first element.
 |
 | @returns The tuple containing the PID of the top supervisor process
 |          and the state of the running application (or an empty list).
 |#
(defun start (_ args)
    "Starts up the daemon.
     It has to be the application module callback, but used directly
     from the startup script of the daemon."

    (let (((tuple port-number daemon-name log) args))

    (let (((tuple 'ok _) (: application ensure_all_started 'cowboy))))

    (let ((dispatch (: cowboy_router compile (list
        (tuple '_ (list
            (tuple "/" 'reqhandler ())
        ))
    ))))

    ; Starting up the plain HTTP listener on <port_number>.
    (let ((ret- (: cowboy start_clear 'http-listener (list (tuple
        'port port-number
    )) (map
        'env (map 'dispatch dispatch)
    ))))))

    (: io put_chars (++
  (macroexpand '(: AUX MSG-SERVER-STARTED-1))
                (integer_to_list port-number) (macroexpand '(: AUX NEW-LINE))
  (macroexpand '(: AUX MSG-SERVER-STARTED-2)) (macroexpand '(: AUX NEW-LINE))))

    (: syslog log log 'info (++
  (macroexpand '(: AUX MSG-SERVER-STARTED-1))
                (integer_to_list port-number) (macroexpand '(: AUX NEW-LINE))
  (macroexpand '(: AUX MSG-SERVER-STARTED-2))))
    )
{'fraction_non_alphanumeric': 0.22029640793770408, 'fraction_numerical': 0.007033408691283597, 'mean_word_length': 3.3329706202393905, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '744025', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1072, 'n_words': 389}