diff --git a/config/config.exs b/config/config.exs index fa494ac..5ecb932 100644 --- a/config/config.exs +++ b/config/config.exs @@ -8,7 +8,7 @@ config :bdfr_browser, BdfrBrowser.Repo, migration_foreign_key: [column: :id, type: :string] config :logger, - backends: [], + backends: [:console], level: :info, handle_otp_reports: false, handle_sasl_reports: false diff --git a/config/prod.exs b/config/prod.exs index 361a52f..becde76 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -1,5 +1 @@ import Config - -config :logger, - backends: [:console], - level: :info diff --git a/config/runtime.exs b/config/runtime.exs index 4379560..d9e7430 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -3,6 +3,7 @@ import Config config :bdfr_browser, base_directory: System.get_env("BDFR_BROWSER_BASE_DIRECTORY", "/nonexistant"), chat_directory: System.get_env("BDFR_BROWSER_CHAT_DIRECTORY", "/nonexistant"), + watch_directories: System.get_env("BDFR_BROWSER_WATCH_DIRECTORIES", "true"), http_ip: to_charlist(System.get_env("BDFR_BROWSER_HTTP_IP", "127.0.0.1")), http_port: String.to_integer(System.get_env("BDFR_BROWSER_HTTP_PORT", "4040")) diff --git a/lib/bdfr_browser/importer.ex b/lib/bdfr_browser/importer.ex index 63a9aaf..2fe452e 100644 --- a/lib/bdfr_browser/importer.ex +++ b/lib/bdfr_browser/importer.ex @@ -80,7 +80,13 @@ defmodule BdfrBrowser.Importer do end def background_import_changes do - GenServer.cast(__MODULE__, :background_import_changes) + watch_directories = Application.fetch_env!(:bdfr_browser, :watch_directories) + + if watch_directories == "true" do + GenServer.cast(__MODULE__, :background_import_changes) + else + background_import() + end end # Callbacks @@ -94,10 +100,18 @@ defmodule BdfrBrowser.Importer do def handle_continue(:setup_fs, state) do base_directory = Application.fetch_env!(:bdfr_browser, :base_directory) chat_directory = Application.fetch_env!(:bdfr_browser, :chat_directory) + watch_directories = Application.fetch_env!(:bdfr_browser, :watch_directories) - {:ok, pid} = FileSystem.start_link(dirs: [base_directory, chat_directory]) - :ok = FileSystem.subscribe(pid) - {:noreply, %State{state | fs_pid: pid}} + fs_pid = + if watch_directories == "true" do + {:ok, pid} = FileSystem.start_link(dirs: [base_directory, chat_directory]) + :ok = FileSystem.subscribe(pid) + pid + else + nil + end + + {:noreply, %State{state | fs_pid: fs_pid}} end @impl true diff --git a/priv/templates/http/chats.eex b/priv/templates/http/chats.eex index 3c58ab2..7feb788 100644 --- a/priv/templates/http/chats.eex +++ b/priv/templates/http/chats.eex @@ -2,7 +2,7 @@
- <%= for chat <- chats do %> + <%= for chat when chat.num_messages > 5 <- chats do %>