I'm trying to figure out how to start an elixir app from command line, preferably jumping into an iex session similar to what erl does. Right now as a workaround, I have a module:
defmodule :cerebrate do
@behavior :application
def start() do
…
end
end
Using an atom as the module name instead of a capitalized name compiles a standard cerebrate.beam file, instead of something within the __MAIN__ directory. From the command line, I call erl -s cerebrate and it starts the application behavior and jumps into an erlang shell. I'd like to instead jump into an iex shell so that I can inspect my modules with elixir syntax. Is that possible?
I tried doing this:
defmodule Cerebrate do
@behavior :application
def start() do
…
end
end
And then running both elixir -e "Cerebrate.start" --no-halt and iex -e "Cerebrate.start" --no-halt but it seems to just hang without print out any feedback.
.Carlo
you don't need to make app file that is auto generated in mix.exs(def project do[ app: Cerebrate,version: "x.x.x" ]enddef application do[mod: {Cerebrate,[]},applications: [:sasl ],description: 'Hello Cerebrate Server App']end)But, The same thing happened to me! this is minimum set.-----defmodule App dodef start do:ok = :application.start(:app)enddef start(_type, arg) do:gen_server.start_link({:local, :app}, AppSrv, arg, [])endenddefmodule AppSrv dodef init(arg) do# :error_logger.info_report('started!') # ok!IO.puts("started!") # hangup!{:ok, []}enddef handle_call({:ping}, _from, state) do{:reply, {:pong}, state}endend---mix.exs is---efmodule App.MixFile douse Mix.Projectdef project do[app: :app,version: "0.0.1",deps: [# Add dependencies here# { :foo_bar, "0.1", git: "https://github.com/foo/bar.git" }]]end# Configuration for the OTP applicationdef application do[mod: {App, []},description: 'minimum app']endend----$ mix clean$ mix iexCompiled lib/app.exGenerated app.appInteractive Elixir (0.7.0.dev) - press Ctrl+C to exitErlang R15B01 (erts-5.9.1) [source] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false]iex(1)> :application.start(:app)BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded(v)ersion (k)ill (D)b-tables (d)istributiona---but, in using error_logger.info_report instead of io.format, :application.start(:app) is success!!
2012年4月16日月曜日 5時47分09秒 UTC+9 Carlo Cabanilla:
Thanks, I pushed simplest otp app with elixir.Cheers.
Thanks.It reappears when I perform it as follows.1. clone app from github.2. $ mix3. $ mix idx4. iex> :application.start(:app)!!! hangup !!! stop for ^C and a