small medium large xlarge

Dave_gnome_head_isolated_pragsmall
15 Jul 2013, 03:42
Dave Thomas (390 posts)
  • Turn your stack server into an OTP application.
Generic-user-small
22 May 2017, 17:38
Matthew Fehskens (8 posts)

As far as I can tell, the changes are almost identical to the Sequence projects:

In lib/stack/application.ex or lib/stack/stack.ex:

defmodule Stack.Application do
  use Application

  def start(_type, _args) do
    import Supervisor.Spec, warn: false
    
    # used to be Stack.Supervisor.start_link([])
    { :ok, _pid } = Stack.Supervisor.start_link(Application.get_env(:stack, :initial_stack))
  end
end

And in mix.exs:

defmodule Stack.Mixfile do
  # omitted `project` function, since there were no changes

  def application do
    # the following used to be
    # [ extra_applications: [:logger],
    #    mode: { Stack.Application, [] }]
    [
      env: [ initial_stack: []],
      extra_applications: [:logger],
      mod: { Stack.Application, [] },
      registered: [ Stack.Server ]
    ]
  end

  defp deps do
    []
  end
end
You must be logged in to comment