From 27bff9e519f58add05e94ab43a65684d913c84f2 Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel Date: Sun, 14 Jul 2019 10:17:55 +1200 Subject: [PATCH] Fix configuration scripts --- config/config.exs | 21 ++++++--- config/poxa.dev.conf | 44 ----------------- config/poxa.prod.conf | 44 ----------------- config/poxa.schema.exs | 104 ----------------------------------------- config/releases.exs | 18 +++++++ rel/env.bat.eex | 6 +++ rel/env.sh.eex | 14 ++++++ rel/vm.args.eex | 11 +++++ 8 files changed, 63 insertions(+), 199 deletions(-) delete mode 100644 config/poxa.dev.conf delete mode 100644 config/poxa.prod.conf delete mode 100644 config/poxa.schema.exs create mode 100644 config/releases.exs create mode 100644 rel/env.bat.eex create mode 100644 rel/env.sh.eex create mode 100644 rel/vm.args.eex diff --git a/config/config.exs b/config/config.exs index 24f0351..ab687af 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config if Mix.env == :test do config :logger, backends: [] end @@ -6,10 +6,17 @@ end import System config :poxa, - port: get_env("PORT") || 8080, - app_key: get_env("POXA_APP_KEY") || "app_key", - app_secret: get_env("POXA_SECRET") || "secret", - app_id: get_env("POXA_APP_ID") || "app_id", - registry_adapter: get_env("POXA_REGISTRY_ADAPTER") || "gproc", - web_hook: get_env("WEB_HOOK") || nil, + port: get_env("PORT", "8080") |> String.to_integer(), + app_key: get_env("POXA_APP_KEY", "app_key"), + app_secret: get_env("POXA_SECRET", "secret"), + app_id: get_env("POXA_APP_ID", "app_id"), + registry_adapter: get_env("POXA_REGISTRY_ADAPTER", "gproc"), + web_hook: get_env("WEB_HOOK", nil), payload_limit: get_env("PAYLOAD_LIMIT") || 10_000 + +config :poxa, :ssl, + enabled: get_env("POXA_SSL", "false") == "true", + port: get_env("SSL_PORT", "8443") |> String.to_integer(), + cacertfile: get_env("SSL_CACERTFILE", ""), + certfile: get_env("SSL_CERTFILE", ""), + keyfile: get_env("SSL_KEYFILE", "") diff --git a/config/poxa.dev.conf b/config/poxa.dev.conf deleted file mode 100644 index 09c9279..0000000 --- a/config/poxa.dev.conf +++ /dev/null @@ -1,44 +0,0 @@ -# HTTP Port -# If not set, will use value of PORT environment variable -poxa.port = 8080 - -# Pusher app key -# If not set, will use value of POXA_APP_KEY environment variable -poxa.app_key = "app_key" - -# Pusher secret -# If not set, will use value of POXA_SECRET environment variable -poxa.app_secret = "secret" - -# Pusher app id -# If not set, will use value of POXA_APP_ID environment variable -poxa.app_id = "app_id" - -# Registry adapter -# If not set, will use value of POXA_REGISTRY_ADAPTER environment variable -poxa.registry_adapter = "gproc" - -# Web hook endpoint -# If not set, will use value of WEB_HOOK environment variable -# poxa.web_hook = - -# HTTPS switch -# If not set, will use value of POXA_SSL environment variable -poxa.ssl.enabled = false - -# HTTPS port -# If not set, will use value of SSL_PORT environment variable -# poxa.ssl.port = - -# PEM-encoded CA certificate path -# If not set, will use value of SSL_CACERTFILE environment variable -# poxa.ssl.cacertfile = - -# Path to user certificate -# If not set, will use value of SSL_CERTFILE environment variable -# poxa.ssl.certfile = - -# Path to the file containing the user's private PEM-encoded key -# If not set, will use value of SSL_KEYFILE environment variable -# poxa.ssl.keyfile = - diff --git a/config/poxa.prod.conf b/config/poxa.prod.conf deleted file mode 100644 index 09c9279..0000000 --- a/config/poxa.prod.conf +++ /dev/null @@ -1,44 +0,0 @@ -# HTTP Port -# If not set, will use value of PORT environment variable -poxa.port = 8080 - -# Pusher app key -# If not set, will use value of POXA_APP_KEY environment variable -poxa.app_key = "app_key" - -# Pusher secret -# If not set, will use value of POXA_SECRET environment variable -poxa.app_secret = "secret" - -# Pusher app id -# If not set, will use value of POXA_APP_ID environment variable -poxa.app_id = "app_id" - -# Registry adapter -# If not set, will use value of POXA_REGISTRY_ADAPTER environment variable -poxa.registry_adapter = "gproc" - -# Web hook endpoint -# If not set, will use value of WEB_HOOK environment variable -# poxa.web_hook = - -# HTTPS switch -# If not set, will use value of POXA_SSL environment variable -poxa.ssl.enabled = false - -# HTTPS port -# If not set, will use value of SSL_PORT environment variable -# poxa.ssl.port = - -# PEM-encoded CA certificate path -# If not set, will use value of SSL_CACERTFILE environment variable -# poxa.ssl.cacertfile = - -# Path to user certificate -# If not set, will use value of SSL_CERTFILE environment variable -# poxa.ssl.certfile = - -# Path to the file containing the user's private PEM-encoded key -# If not set, will use value of SSL_KEYFILE environment variable -# poxa.ssl.keyfile = - diff --git a/config/poxa.schema.exs b/config/poxa.schema.exs deleted file mode 100644 index ae01bd8..0000000 --- a/config/poxa.schema.exs +++ /dev/null @@ -1,104 +0,0 @@ -[ - extends: [], - import: [], - mappings: [ - "poxa.port": [ - commented: false, - datatype: :integer, - default: 8080, - doc: "HTTP Port", - hidden: false, - env_var: "PORT", - to: "poxa.port" - ], - "poxa.app_key": [ - commented: false, - datatype: :binary, - default: "app_key", - doc: "Pusher app key", - hidden: false, - env_var: "POXA_APP_KEY", - to: "poxa.app_key" - ], - "poxa.app_secret": [ - commented: false, - datatype: :binary, - default: "secret", - doc: "Pusher secret", - hidden: false, - env_var: "POXA_SECRET", - to: "poxa.app_secret" - ], - "poxa.app_id": [ - commented: false, - datatype: :binary, - default: "app_id", - doc: "Pusher app id", - hidden: false, - env_var: "POXA_APP_ID", - to: "poxa.app_id" - ], - "poxa.registry_adapter": [ - commented: false, - datatype: :binary, - default: "gproc", - doc: "Registry adapter", - hidden: false, - env_var: "POXA_REGISTRY_ADAPTER", - to: "poxa.registry_adapter" - ], - "poxa.web_hook": [ - commented: false, - datatype: :binary, - doc: "Web hook endpoint", - hidden: false, - default: "", - env_var: "WEB_HOOK", - to: "poxa.web_hook" - ], - "poxa.ssl.enabled": [ - doc: "HTTPS switch", - to: "poxa.ssl.enabled", - datatype: :boolean, - env_var: "POXA_SSL", - default: false, - ], - "poxa.ssl.port": [ - doc: "HTTPS port", - to: "poxa.ssl.port", - env_var: "SSL_PORT", - default: 8443, - datatype: :integer, - ], - "poxa.ssl.cacertfile": [ - doc: "PEM-encoded CA certificate path", - to: "poxa.ssl.cacertfile", - env_var: "SSL_CACERTFILE", - default: "", - datatype: :binary, - ], - "poxa.ssl.certfile": [ - doc: "Path to user certificate", - to: "poxa.ssl.certfile", - env_var: "SSL_CERTFILE", - default: "", - datatype: :binary, - ], - "poxa.ssl.keyfile": [ - doc: "Path to the file containing the user's private PEM-encoded key", - to: "poxa.ssl.keyfile", - env_var: "SSL_KEYFILE", - default: "", - datatype: :binary, - ], - "poxa.payload_limit": [ - doc: "Payload limit for a message", - to: "poxa.payload_limit", - env_var: "PAYLOAD_LIMIT", - default: 10_000, - datatype: :integer, - ], - ], - transforms: [], - validators: [] -] diff --git a/config/releases.exs b/config/releases.exs new file mode 100644 index 0000000..bd139e0 --- /dev/null +++ b/config/releases.exs @@ -0,0 +1,18 @@ +import Config +import System + +config :poxa, + port: get_env("PORT", "8080") |> String.to_integer(), + app_key: get_env("POXA_APP_KEY", "app_key"), + app_secret: get_env("POXA_SECRET", "secret"), + app_id: get_env("POXA_APP_ID", "app_id"), + registry_adapter: get_env("POXA_REGISTRY_ADAPTER", "gproc"), + web_hook: get_env("WEB_HOOK", nil), + payload_limit: get_env("PAYLOAD_LIMIT") || 10_000 + +config :poxa, :ssl, + enabled: get_env("POXA_SSL", "false") == "true", + port: get_env("SSL_PORT", "8443") |> String.to_integer(), + cacertfile: get_env("SSL_CACERTFILE", ""), + certfile: get_env("SSL_CERTFILE", ""), + keyfile: get_env("SSL_KEYFILE", "") diff --git a/rel/env.bat.eex b/rel/env.bat.eex new file mode 100644 index 0000000..482ffaf --- /dev/null +++ b/rel/env.bat.eex @@ -0,0 +1,6 @@ +@echo off +rem Set the release to work across nodes. If using the long name format like +rem the one below (my_app@127.0.0.1), you need to also uncomment the +rem RELEASE_DISTRIBUTION variable below. +rem set RELEASE_DISTRIBUTION=name +rem set RELEASE_NODE=<%= @release.name %>@127.0.0.1 diff --git a/rel/env.sh.eex b/rel/env.sh.eex new file mode 100644 index 0000000..6a0e6b1 --- /dev/null +++ b/rel/env.sh.eex @@ -0,0 +1,14 @@ +#!/bin/sh + +# Sets and enables heart (recommended only in daemon mode) +# if [ "$RELEASE_COMMAND" = "daemon" ] || [ "$RELEASE_COMMAND" = "daemon_iex" ]; then +# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND" +# export HEART_COMMAND +# export ELIXIR_ERL_OPTIONS="-heart" +# fi + +# Set the release to work across nodes. If using the long name format like +# the one below (my_app@127.0.0.1), you need to also uncomment the +# RELEASE_DISTRIBUTION variable below. +# export RELEASE_DISTRIBUTION=name +# export RELEASE_NODE=<%= @release.name %>@127.0.0.1 diff --git a/rel/vm.args.eex b/rel/vm.args.eex new file mode 100644 index 0000000..71e8032 --- /dev/null +++ b/rel/vm.args.eex @@ -0,0 +1,11 @@ +## Customize flags given to the VM: http://erlang.org/doc/man/erl.html +## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here + +## Number of dirty schedulers doing IO work (file, sockets, etc) +##+SDio 5 + +## Increase number of concurrent ports/sockets +##+Q 65536 + +## Tweak GC to run more often +##-env ERL_FULLSWEEP_AFTER 10