Заранее извиняюсь за тупой вопрос.
Хочу запустить пример из документации: https://maru.readme.io/docs/basic-usage
Что я делаю не так?
mix.exs
defmodule MyApp.MixProject do
use Mix.Project
def project do
[
app: :my_app,
version: "0.1.0",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
#extra_applications: [:logger],
applications: [:maru]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:maru, "~> 0.13"},
{:cowboy, "~> 2.3"},
{:jason, "~> 1.0"},
]
end
end
config/config.exs:
use Mix.Config
# config/config.exs
config :my_app, MyAPP.Server,
adapter: Plug.Adapters.Cowboy2,
plug: MyAPP.API,
scheme: :http,
port: 8880
config :my_app,
maru_servers: [MyAPP.Server]
lib/my_app.ex:
defmodule MyAPP.Server do
use Maru.Server, otp_app: :my_app
end
# Add MyAPP.Server to Your Supervisor Tree
defmodule MyAPP.Supervisor do
use Supervisor
def init(_arg) do
children = [
MyAPP.Server
]
Supervisor.init(children, strategy: :one_for_one)
end
end
defmodule MyAPP.Router.Homepage do
use MyAPP.Server
get do
json(conn, %{ hello: :world })
end
end
defmodule MyAPP.API do
use MyAPP.Server
mount MyAPP.Router.Homepage
rescue_from :all do
conn
|> put_status(500)
|> text("Server Error")
end
end
Но запускается только интерактивная оболочка.
my_app ➤ iex -S mix
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]
Generated my_app app
Interactive Elixir (1.14.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>