Current section
Files
Jump to
Current section
Files
priv/template/lib/app_name/application.ex.eex
defmodule <%= @module %>.Application do
@moduledoc false
use Application
def start(_type, _args) do
config = %{}
cleartext_options = [port: 8080, cleartext: true]
secure_options = [port: 8443, cleartext: :false, certfile: certificate_path(), keyfile: certificate_key_path()]
children = [
Supervisor.child_spec({<%= @module %>.WWW, [config, cleartext_options]}, id: :www_cleartext),
Supervisor.child_spec({<%= @module %>.WWW, [config, secure_options]}, id: :www_secure),
<%= if @node_assets do %>
Supervisor.child_spec({Task, fn() -> System.cmd("npm", ["run", "watch:js"], cd: "lib/<%= @name %>/www") end}, id: :watch_js),
<% end %>
]
opts = [strategy: :one_for_one, name: <%= @module %>.Supervisor]
Supervisor.start_link(children, opts)
end
defp certificate_path() do
Application.app_dir(:<%= @name %>, "priv/localhost/certificate.pem")
end
defp certificate_key_path() do
Application.app_dir(:<%= @name %>, "priv/localhost/certificate_key.pem")
end
end