Skip to content

Commit

Permalink
Merge pull request #12 from joshuafleck/config_timeout
Browse files Browse the repository at this point in the history
Make amount of sleep between attempts configurable
  • Loading branch information
Joshua Fleck authored Jan 21, 2017
2 parents a358573 + c9e8781 commit 613c4fd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ config :ex_ngrok,
port: "4000",
# The URL of Ngrok's API (used to retrieve its settings)
api_url: "http://localhost:4040/api/tunnels",
# The amount of sleep (in ms) to put between attempts to connect to Ngrok
sleep_between_attempts: 200,
# Any other tunneling options that will be passed directly to Ngrok
options: ""
```
Expand Down
2 changes: 1 addition & 1 deletion lib/settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Ngrok.Settings do
defp tunnel_settings(), do: tunnel_settings(0, "")
defp tunnel_settings(6, error_message), do: raise "Unable to retrieve setting from Ngrok: #{error_message}"
defp tunnel_settings(total_attempts, _) do
:timer.sleep(total_attempts * 100)
:timer.sleep(total_attempts * Application.get_env(:ex_ngrok, :sleep_between_attempts))
case Ngrok.Api.tunnel_settings do
{:ok, settings} ->
settings
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Ngrok.Mixfile do

def project do
[app: :ex_ngrok,
version: "0.3.1",
version: "0.3.2",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
Expand All @@ -20,6 +20,7 @@ defmodule Ngrok.Mixfile do
executable: "ngrok",
protocol: "http",
port: "4000",
sleep_between_attempts: 200,
options: "",
],
mod: {Ngrok, []}]
Expand Down

0 comments on commit 613c4fd

Please sign in to comment.