Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 22 lines (20 sloc) 0.753 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
-module(ernie_server_sup).
-behaviour(supervisor).
-export([start_link/0, init/1]).

start_link() ->
  supervisor:start_link({local, ?MODULE}, ?MODULE, []).

init([]) ->
  {ok, Port} = application:get_env(ernie_server_app, port),
  io:format("Using port ~p~n", [Port]),
  case application:get_env(ernie_server_app, pidfile) of
    {ok, Location} ->
      Pid = os:getpid(),
      ok = file:write_file(Location, list_to_binary(Pid));
    undefined -> ok
  end,
  {ok, Config} = application:get_env(ernie_server_app, config),
  {ok, Configs} = ernie_config:load(Config),
  io:format("~p~n", [Configs]),
  {ok, {{one_for_one, 1, 60},
    [{ernie_server, {ernie_server, start_link, [[Port, Configs]]},
    permanent, brutal_kill, worker, [ernie_server]}]}}.
Something went wrong with that request. Please try again.