Compare commits
5 Commits
e333bc121b
...
ee20a5e5d6
Author | SHA1 | Date |
---|---|---|
tali | ee20a5e5d6 | |
tali | 25c28bf797 | |
tali | 0470cb85d0 | |
tali | b113247f48 | |
tali | 704afb4409 |
52
bin/main.ml
52
bin/main.ml
|
@ -1,12 +1,50 @@
|
|||
Logging.init_pretty_writer stderr
|
||||
~min_level:TRACE;
|
||||
let min_level =
|
||||
match Sys.getenv_opt "LOG_LEVEL" |> Option.map String.uppercase_ascii with
|
||||
| Some "TRACE" -> Logging.TRACE
|
||||
| Some "DEBUG" -> Logging.TRACE
|
||||
| Some "INFO" -> Logging.TRACE
|
||||
| Some ("WARN" | "WARNING") -> Logging.TRACE
|
||||
| Some ("ERR" | "ERROR") -> Logging.TRACE
|
||||
| _ -> Logging.INFO
|
||||
|
||||
Lwt_main.run
|
||||
(Server.run {
|
||||
port = 6667;
|
||||
let no_color = Option.is_some (Sys.getenv_opt "LOG_NO_COLOR")
|
||||
let no_timestamp = Option.is_some (Sys.getenv_opt "LOG_NO_TIMESTAMP")
|
||||
let no_namespace = Option.is_some (Sys.getenv_opt "LOG_NO_NAMESPACE")
|
||||
|
||||
let () =
|
||||
match Sys.getenv_opt "JOURNAL_STREAM" with
|
||||
| Some _ ->
|
||||
Logging.init_journald_writer ()
|
||||
~min_level
|
||||
| None ->
|
||||
Logging.init_pretty_writer stderr
|
||||
~min_level
|
||||
~color:(not no_color)
|
||||
~timestamp:(not no_timestamp)
|
||||
~namespace:(not no_namespace)
|
||||
|
||||
let port =
|
||||
try
|
||||
let port = int_of_string (Sys.getenv "IRC_PORT") in
|
||||
if port <= 0 || port > 65535 then failwith "invalid port";
|
||||
port
|
||||
with _ ->
|
||||
6667
|
||||
|
||||
let hostname =
|
||||
match Sys.getenv_opt "IRC_HOSTNAME" with
|
||||
| Some x -> x
|
||||
| None -> "irc.tali.software"
|
||||
|
||||
let config : Server.config = {
|
||||
port;
|
||||
hostname;
|
||||
listen_backlog = 8;
|
||||
ping_interval = 60;
|
||||
whowas_history_len = 1000;
|
||||
hostname = "irc.tali.software";
|
||||
|
||||
(* TODO: motd *)
|
||||
})
|
||||
}
|
||||
|
||||
let () =
|
||||
Lwt_main.run @@ Server.run config
|
||||
|
|
|
@ -5,4 +5,9 @@
|
|||
(name talircd)
|
||||
(depends
|
||||
ocaml
|
||||
dune))
|
||||
dune
|
||||
(lwt (= 5.7.0))
|
||||
(ppx_expect (= v0.16.0))
|
||||
(ppx_deriving (= 5.2.1))
|
||||
(fmt (= 0.9.0))
|
||||
(ptime (= 1.1.0))))
|
||||
|
|
|
@ -457,7 +457,7 @@ let on_msg_join t name =
|
|||
DON'T try to make a new channel *)
|
||||
Error (nosuchchannel name)
|
||||
with Not_found ->
|
||||
debug (fun m -> m "making new channel %S" name);
|
||||
info (fun m -> m "making new channel %S" name);
|
||||
Ok (Chan.make name)
|
||||
in
|
||||
match Router.membership chan me with
|
||||
|
@ -495,7 +495,7 @@ let leave t mem ~from ~why =
|
|||
Router.part mem;
|
||||
if Chan.is_empty chan then
|
||||
begin
|
||||
debug (fun m -> m "recycling empty channel %S" (Chan.name chan));
|
||||
info (fun m -> m "recycling empty channel %S" (Chan.name chan));
|
||||
Chan.unregister chan ~router:t.router;
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
open Irc
|
||||
|
||||
type t
|
||||
|
||||
val make :
|
||||
router:Router.t ->
|
||||
server_info:Server_info.t ->
|
||||
addr:Unix.sockaddr ->
|
||||
t
|
||||
|
||||
val close : ?reason:string -> t -> unit
|
||||
|
||||
val outbox : t -> Outbox.t
|
||||
val on_msg : t -> Msg.t -> unit
|
||||
val on_ping : t -> (unit, unit) result
|
|
@ -3,6 +3,11 @@ opam-version: "2.0"
|
|||
depends: [
|
||||
"ocaml"
|
||||
"dune" {>= "3.8"}
|
||||
"lwt" {= "5.7.0"}
|
||||
"ppx_expect" {= "v0.16.0"}
|
||||
"ppx_deriving" {= "5.2.1"}
|
||||
"fmt" {= "0.9.0"}
|
||||
"ptime" {= "1.1.0"}
|
||||
"odoc" {with-doc}
|
||||
]
|
||||
build: [
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=tali IRCd
|
||||
|
||||
[Service]
|
||||
Environment=IRC_HOSTNAME=irc.tali.software
|
||||
#Environment=IRC_PORT=6667
|
||||
#Environment=LOG_LEVEL=DEBUG
|
||||
ExecStart=/usr/local/bin/talircd
|
Loading…
Reference in New Issue