#lang racket

(require "loop.rkt"
         (except-in "vars.rkt" log)
         "git-version.rkt"
         "clearenv.rkt"
         (only-in "servers.rkt" real-server)
         (only-in "userinfo.rkt" *userinfo-database-directory-name*)
         (only-in "iserver.rkt" make-incubot-server)

         version/utils)

(module+ main
  (let ([required-version "5.2.900.1"])
    (when (not (>= (version->integer (version))
                   (version->integer required-version)))
      (error 'freenode-main "You need at least version ~a of racket, to avoid a memory leak in sqlite" required-version)))

  (clearenv)
  (command-line
   #:program "rudybot"
   #:once-each)

  TODO -- the equivalent of " echo -17 > /proc / self / oom_adj " , to
  ;; immunize this process from being killed by the dreaded oom_killer
  ;; (it happened once).  See -mm.org/OOM_Killer

  (log "Main starting: ~a" (git-version))

  (parameterize* ([*irc-server-hostname* "irc.libera.chat"]
                  [*irc-server-port* 6697]
                  [*userinfo-database-directory-name* "userinfo.db"]
                  [*incubot-logger* log]
                  [*incubot-server* (make-incubot-server)])

    (if (*nickserv-password*)
        (connect-and-run real-server)
        (error 'freenode-main "You didn't specify a NickServ password"))))

(provide (all-defined-out))

 immunize this process from being killed by the dreaded oom_killer
 (it happened once).  See -mm.org/OOM_Killer
#lang racket

(require "loop.rkt"
         (except-in "vars.rkt" log)
         "git-version.rkt"
         "clearenv.rkt"
         (only-in "servers.rkt" real-server)
         (only-in "userinfo.rkt" *userinfo-database-directory-name*)
         (only-in "iserver.rkt" make-incubot-server)

         version/utils)

(module+ main
  (let ([required-version "5.2.900.1"])
    (when (not (>= (version->integer (version))
                   (version->integer required-version)))
      (error 'freenode-main "You need at least version ~a of racket, to avoid a memory leak in sqlite" required-version)))

  (clearenv)
  (command-line
   #:program "rudybot"
   #:once-each)

  TODO -- the equivalent of " echo -17 > /proc / self / oom_adj " , to

  (log "Main starting: ~a" (git-version))

  (parameterize* ([*irc-server-hostname* "irc.libera.chat"]
                  [*irc-server-port* 6697]
                  [*userinfo-database-directory-name* "userinfo.db"]
                  [*incubot-logger* log]
                  [*incubot-server* (make-incubot-server)])

    (if (*nickserv-password*)
        (connect-and-run real-server)
        (error 'freenode-main "You didn't specify a NickServ password"))))

(provide (all-defined-out))
