elixir - umbrella 项目, ( phoenix, mix )

访问量: 450

参考 https://elixir-lang.org/getting-started/mix-otp/dependencies-and-umbrella-projects.html

使用mix 来创建 umbrella项目:

$ mix new test_umbrella --umbrella
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating apps
* creating config
* creating config/config.exs

文件特别少:几乎没有创建内容:

find . 
.
./README.md
./.gitignore
./mix.exs
./.formatter.exs
./apps
./config
./config/config.exs

可以进一步创建一个 子应用:

siwei@ubuntu:/workspace/test_umbrella/apps$ mix new hi_server --module HiServer --sup
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/hi_server.ex
* creating lib/hi_server/application.ex
* creating test
* creating test/test_helper.exs
* creating test/hi_server_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd hi_server
    mix test

Run "mix help" for more commands.

查看该文件夹,发现内容也不多:

siwei@ubuntu:/workspace/test_umbrella/apps/hi_server$ find . 
.
./README.md
./.gitignore
./mix.exs
./test
./test/hi_server_test.exs
./test/test_helper.exs
./lib
./lib/hi_server
./lib/hi_server/application.ex
./lib/hi_server.ex
./.formatter.exs

上面的重点文件是 mix.exs, 它的内容解释如下:

上面红色代表,表示 要看这个子应用的parent应用。

还有个很重要的文件  application.ex

如上图所示, Supervisor 是elixir / mix 的重要内容,算是可以启动该线程的办法

订阅/RSS Feed

Subscribe