Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

can't get proper value from application env #12

Closed
wants to merge 4 commits into from

1 participant

@coolluck

The function application:get_env return " undefined | {ok, term()} "

When I setting application env for example listening port or something,
it cause crash like below.

ERROR: "Bigwig listening on http://~s:~B/~n" - ["127.0.0.1",
{ok,
20829}]

=CRASH REPORT==== 13-Apr-2012::08:49:18 ===
crasher:
initial call: supervisor:cowboy_acceptors_sup/1
pid: <0.75.0>
registered_name: []
exception exit: {function_clause,
[{inet_tcp,getserv,
[{ok,20829}],
[{file,"inet_tcp.erl"},{line,35}]},
{gen_tcp,listen,2,[{file,"gen_tcp.erl"},{line,182}]},
{cowboy_acceptors_sup,init,1,
[{file,"src/cowboy_acceptors_sup.erl"},
{line,42}]},
{supervisor,init,1,
[{file,"supervisor.erl"},{line,233}]},
{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,304}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}
in function gen_server:init_it/6 (gen_server.erl, line 328)
ancestors: [<0.72.0>,cowboy_sup,<0.58.0>]
messages: []
links: [<0.72.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 987
stack_size: 24
reductions: 171
neighbours:

Please consider this pull request.
Thank you for reading.

Minsu Choi added some commits
@coolluck coolluck closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2012
  1. fix bug using confval

    Minsu Choi authored
    can't get proper value from application env
Commits on Apr 13, 2012
  1. change port for network environment.

    Minsu Choi authored
  2. using OTP R15

    Minsu Choi authored
  3. change default listening ip(localhost) to hostname

    Minsu Choi authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +1 −1  rebar.config
  2. +1 −1  src/bigwig.app.src
  3. +3 −2 src/bigwig_http.erl
View
2  rebar.config
@@ -1,6 +1,6 @@
{erl_opts, [debug_info]}. %, fail_on_warning]}.
-{require_otp_vsn, "R14"}.
+{require_otp_vsn, "R15"}.
{deps_dir, ["deps"]}.
View
2  src/bigwig.app.src
@@ -8,5 +8,5 @@
stdlib
]},
{mod, { bigwig_app, []}},
- {env, []}
+ {env, [{port, 28989}]}
]}.
View
5 src/bigwig_http.erl
@@ -39,12 +39,13 @@ dispatch_rules() ->
confval(Key, Default) ->
case application:get_env(Key) of
undefined -> Default;
- Val -> Val
+ {ok, Val} -> Val
end.
init([]) ->
Port = confval(port, 40829),
- Ip = confval(ip, "127.0.0.1"),
+ {ok, Hostname} = inet:gethostname(),
+ Ip = confval(ip, Hostname),
NumAcceptors = confval(num_acceptors, 16),
IpStr = case is_list(Ip) of true -> Ip; false -> inet_parse:ntoa(Ip) end,
Something went wrong with that request. Please try again.