Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## websocket_app.erl
-module(websocket_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
PublicDispatch = cowboy_router:compile (
[{'_', [
{"/", cowboy_static, {file, "/root/client/index.html"}},
{"/info.html", cowboy_static, {file, "/root/client/info.html"}},
{"/out/[...]", cowboy_static, {dir, "/root/client/resources/release/out/"}},
{"/websocket", ws_handler, []},
{"/static/[...]", cowboy_static, {priv_dir, websocket, "static"}}]}]),
{ok, _} = cowboy:start_http(http, 100, [{port, 8080}],
[{env, [{dispatch, PublicDispatch}]}]),
PrivateDispatch = cowboy_router:compile (
[{'_', [
{"/", cowboy_static, {file, "/root/client/index.html"}},
{"/info.html", cowboy_static, {file, "/root/client/info.html"}},
{"/out/[...]", cowboy_static, {dir, "/root/client/resources/dev/out/"}},
{"/websocket", ws_handler, []},
{"/static/[...]", cowboy_static, {priv_dir, websocket, "static"}}]}]),
{ok, _} = cowboy:start_http(http, 100, [{port, 7070}],
[{env, [{dispatch, PrivateDispatch}]}]),
websocket_sup:start_link().
stop(_State) ->
ok.
## Error:
_rel/bin/websocket_example console
Exec: /root/server/_rel/erts-6.0/bin/erlexec -boot /root/server/_rel/releases/1/websocket_example -env ERL_LIBS /root/server/_rel/releases/1/lib -config /root/server/_rel/releases/1/sys.config -args_file /root/server/_rel/releases/1/vm.args -- console
Root: /root/server/_rel
Erlang/OTP 17 [RELEASE CANDIDATE 2] [erts-6.0] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
=INFO REPORT==== 9-Mar-2014::03:07:51 ===
application: websocket
exited: {bad_return,
{{websocket_app,start,[normal,[]]},
{'EXIT',
{{badmatch,{error,{already_started,<0.53.0>}}},
[{websocket_app,start,2,
[{file,"src/websocket_app.erl"},{line,26}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,272}]}]}}}}
type: permanent
Eshell V6.0 (abort with ^G)
(websocket_example@127.0.0.1)1> {"Kernel pid terminated",application_controller,"{application_start_failure,websocket,{bad_return,{{websocket_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{already_started,<0.53.0>}}},[{websocket_app,start,2,[{file,\"src/websocket_app.erl\"},{line,26}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,272}]}]}}}}}"}
Crash dump was written to: erl_crash.dump
Kernel pid terminated (application_controller) ({application_start_failure,websocket,{bad_return,{{websocket_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{already_started,<0.53.0>}}},[{websocket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment