From bd3cb7ac8ef2b44ad5026cc7bf2058fc699bc3b1 Mon Sep 17 00:00:00 2001 From: Doc Ritezel Date: Sun, 4 Feb 2018 23:49:28 -0800 Subject: [PATCH] Add pgbouncer wrapper script --- Procfile | 4 ++-- bin/start-pgbouncer-stunnel | 4 ++++ config/prod.exs | 14 +++++++++----- lib/explorer/exq_node_identifier.ex | 5 +++++ 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100755 bin/start-pgbouncer-stunnel create mode 100644 lib/explorer/exq_node_identifier.ex diff --git a/Procfile b/Procfile index 9ebfcf0148..d217ecb56a 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: mix phx.server -worker: mix exq.start +web: bin/start-pgbouncer-stunnel mix phx.server +worker: bin/start-pgbouncer-stunnel mix exq.start diff --git a/bin/start-pgbouncer-stunnel b/bin/start-pgbouncer-stunnel new file mode 100755 index 0000000000..5c800c0d47 --- /dev/null +++ b/bin/start-pgbouncer-stunnel @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Placeholder for pgbouncer buildpack + +$@ diff --git a/config/prod.exs b/config/prod.exs index 22470cd2bc..3075af2128 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -18,8 +18,8 @@ config :explorer, ExplorerWeb.Endpoint, force_ssl: [rewrite_on: [:x_forwarded_proto]], instrumenters: [NewRelixir.Instrumenters.Phoenix], load_from_system_env: true, - pubsub: [adapter: Phoenix.PubSub.Redis, url: Map.fetch!(System.get_env(), "REDIS_URL"), node_name: System.get_env("DYNO")], - secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE"), + pubsub: [adapter: Phoenix.PubSub.Redis, url: System.get_env("REDIS_URL"), node_name: System.get_env("DYNO")], + secret_key_base: System.get_env("SECRET_KEY_BASE"), url: [scheme: "https", host: Map.fetch!(System.get_env(), "HEROKU_APP_NAME") <> ".herokuapp.com", port: 443] # Do not print debug messages in production @@ -30,7 +30,10 @@ config :explorer, Explorer.Repo, adapter: Ecto.Adapters.Postgres, url: System.get_env("DATABASE_URL"), pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), - ssl: true + ssl: false, + prepare: :unnamed, + timeout: 60_000, + pool_timeout: 60_000 # Configure New Relic config :new_relixir, @@ -52,5 +55,6 @@ config :explorer, Explorer.Scheduler, # Configure Exq config :exq, - url: {:system, "REDIS_URL"}, - concurrency: 10 + concurrency: String.to_integer(System.get_env("EXQ_CONCURRENCY") || "3"), + node_identifier: Explorer.ExqNodeIdentifier, + url: System.get_env("REDIS_URL") diff --git a/lib/explorer/exq_node_identifier.ex b/lib/explorer/exq_node_identifier.ex new file mode 100644 index 0000000000..f349047b38 --- /dev/null +++ b/lib/explorer/exq_node_identifier.ex @@ -0,0 +1,5 @@ +defmodule Explorer.ExqNodeIdentifier do + @behaviour Exq.NodeIdentifier.Behaviour + @moduledoc "Configure Exq with the current dyno name" + def node_id, do: System.get_env("DYNO") +end