myapp_sup.erl 675 B

123456789101112131415161718192021222324252627
  1. -module(myapp_sup).
  2. -behaviour(supervisor).
  3. -export([start_link/0, init/1]).
  4. start_link() ->
  5. supervisor:start_link({local, ?MODULE}, ?MODULE, []).
  6. init(_Args) ->
  7. ets:new(events_table, [set, named_table, { keypos, 1 }, public, {write_concurrency, true}]),
  8. Procs = [
  9. #{id => worker_1,
  10. start => {myapp_events, start_link, []},
  11. restart => permanent,
  12. type => worker,
  13. modules => [myapp_events]},
  14. #{id => worker_2,
  15. start => {myapp_events2, start_link, []},
  16. restart => permanent,
  17. type => worker,
  18. modules => [myapp_events2]} ],
  19. {ok, { #{strategy => one_for_one, intensity => 10, period => 100}, Procs}}.