03 アプリの起動 - ohr486/elixir_handson_demo2 GitHub Wiki

03-アプリの起動

Phoenixアプリの起動は、mixコマンドを使って行います。 mixコマンドでできることをmix helpで表示すると、mix phx.serverがあるので、これを使います。

$ mix phx.server
[info] Running DemoWeb.Endpoint with Cowboy using http://0.0.0.0:4000
17:44:13 - info: compiled 6 files into 2 files, copied 3 in 830 ms

これでアプリが起動しました。 ブラウザでlocalhostの4000番ポートを開くとPhoenixアプリが確認できます。

アプリ起動

アプリを停止するには、コントロールキーとCを同時に押して以下の表示を出し、 aボタンを押すことで停止(abort)する事ができます。

^C
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
a
$

また、iex -S mix phx.serverでも起動する事ができ、 この場合はElixirのREPLも一緒に立ち上がります。

$ ❯❯❯ iex -S mix phx.server                                                                                                                      
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

[info] Running DemoWeb.Endpoint with Cowboy using http://0.0.0.0:4000
Interactive Elixir (1.5.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 17:47:24 - info: compiled 6 files into 2 files, copied 3 in 769 ms

nil
iex(2)> 1 + 1
2
iex(3)>

アプリの停止は同様に、コントロールキーとCを同時に押して、aボタンを押せばアプリが停止します。

それではPhoenixアプリのベースができたので、このアプリにページを追加していきましょう。

NEXT:04-画面説明