From 0b1dad86a037d6240e45125e97a067ec618a2951 Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 1 Apr 2021 11:26:19 -0700 Subject: [PATCH] Start console monitor before socket, check for mix in OSS --- lib/console/application.ex | 2 +- lib/console_web/plug/rate_limit.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/console/application.ex b/lib/console/application.ex index 33a92e4f1..108f1e135 100644 --- a/lib/console/application.ex +++ b/lib/console/application.ex @@ -12,9 +12,9 @@ defmodule Console.Application do # Start the Ecto repository supervisor(Console.Repo, []), # Start the endpoint when the application starts + worker(ConsoleWeb.Monitor, [%{}]), supervisor(ConsoleWeb.Endpoint, []), supervisor(Absinthe.Subscription, [ConsoleWeb.Endpoint]), - worker(ConsoleWeb.Monitor, [%{}]), # Start your own worker by calling: Console.Worker.start_link(arg1, arg2, arg3) # worker(Console.Worker, [arg1, arg2, arg3]), {Task.Supervisor, name: ConsoleWeb.TaskSupervisor}, diff --git a/lib/console_web/plug/rate_limit.ex b/lib/console_web/plug/rate_limit.ex index afb0c9835..0e557ce02 100644 --- a/lib/console_web/plug/rate_limit.ex +++ b/lib/console_web/plug/rate_limit.ex @@ -6,7 +6,7 @@ defmodule ConsoleWeb.Plug.RateLimit do def call(conn, [action, limit]) do ip_address = conn |> get_req_header("cf-connecting-ip") |> List.first() - if Mix.env == :test do + if Application.get_env(:console, :env) == :test do conn else case Hammer.check_rate("#{action}:#{ip_address}", 60_000, limit) do