From 5e48d7470cc767e7236f7c90b665ccb9f9f082ff Mon Sep 17 00:00:00 2001 From: tormaroe Date: Wed, 23 May 2012 14:09:22 +0200 Subject: [PATCH] Added OTP supervisor template following normal conventions --- snippets/erlang.snippets | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index 3770ef7..acc6fd1 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -82,6 +82,29 @@ snippet application stop(_State) -> ok. +# OTP supervisor +snippet supervisor + -module(${1:`Filename('', 'my')`}). + + -behaviour(supervisor). + + %% API + -export([start_link/0]). + + %% Supervisor callbacks + -export([init/1]). + + -define(SERVER, ?MODULE). + + start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + + init([]) -> + Server = {${2:my_server}, {$2, start_link, []}, + permanent, 2000, worker, [$2]}, + Children = [Server], + RestartStrategy = {one_for_one, 0, 1}, + {ok, {RestartStrategy, Children}}. # OTP gen_server snippet gen_server -module(${1:`Filename('', 'my')`}).