channels & MVC components currently support user interfaces & directly communicate with biz backend
here these will refactored into child apps
running Videologue starts multiple Applications alongside; Supervisors start/stop apps as unit using Supervision Tree details
-
can start
:observer.start()atiex -S mix; it allows understanding running processes for app -
in processes tab, ordering process by MsgQueue size might allow see the bottleneck
-
Applications tab show all applications & its Supervision Tree; it will miss the server since
iex -S mix phx.serverwasn't started
processes can be killed from here to check
- moving to umbrella, can keep Web & Backend separate as separate Applications but in same repository without version issues
-
each Umbrella project has a parent dir which contains
appsdir & share config for projects -
can use
mix new videologue --umbrella; but let'smix phx.new videologue --umbrellaas it will automate some web-based path & config generation
let's press
nfor dependency install; as we'll copy existing elixir and js code; we havevideologue_umbrellaproject now
- using
phx.new ... --umbrellaauto createsvideologue_umbrella/apps/{videologue,videologue_web}
- new created
appsconfiguration would be like
def project do
[
app: :some_web,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
...
defp deps do
[
{:phoenix, "~> 1.5.9"},
...
{:videologue, in_umbrella: true},
...
]
endall children apps share same config & dependency; are isolate but ran on same VM
- copy over content for
videologueapp
cp -R videologue/lib/videologue videologue_umbrella/apps/videologue/lib
cp videologue/lib/videologue.ex videologue_umbrella/apps/videologue/lib
cp -R videologue/test/videologue videologue_umbrella/apps/videologue/test
cp -R videologue/priv/repo videologue_umbrella/apps/videologue/priv
cp videologue/test/support/data_case.ex videologue_umbrella/apps/videologue/test/support
cp videologue/test/test_helper.exs videologue_umbrella/apps/videologue/test
update videologue_umbrella/videologue/application to have only
Repounder children
children = [
Videologue.Repo,
]
- copy content for
videologue_webapp
cp -R videologue/lib/videologue_web videologue_umbrella/apps/videologue_web/lib
cp -R videologue/lib/videologue_web.ex videologue_umbrella/apps/videologue_web/lib
cp -R videologue/test/videologue_web videologue_umbrella/apps/videologue_web/test
cp -R videologue/test/support/conn_case.ex videologue_umbrella/apps/videologue_web/test/support
update
endpoint.exto have:videologue_webasotp_appattrib &fromunderPlug.Staticalso update
otp_appunderpresence.ex& addVideologue.Presenceunder Applications's children tree & also{Phoenix.PubSub, name: Videologue.PubSub}
- copy assets
cp -R videologue/assets/js videologue_umbrella/apps/videologue_web/assets/js
cp -R videologue/assets/css videologue_umbrella/apps/videologue_web/assets/css
check dep paths under
apps/videologue_web/assets/pacakge.jsonto point for root umbrella
- add
config :videologue, phoenix_token_salt: ..to configs
mix deps.get
pushd apps/videologue_web/assets ; npm install ; popd
- add
config :pbkdf2_elixir, :rounds, 1to test config
[Chapter-12 OTP](./chapter-12.md