Skip to content

Instantly share code, notes, and snippets.

@zeisss
Forked from ericbmerritt/*.app.src
Created August 31, 2013 14:42
Show Gist options
  • Save zeisss/6398650 to your computer and use it in GitHub Desktop.
Save zeisss/6398650 to your computer and use it in GitHub Desktop.
{application, <App Name>,
[{description, "<App Description>"},
{vsn, "<App Version>"},
{modules, [<Module List>]},
{registered, [<Registered Modules]},
{applications, [<Dependency List>]},
{mod, {<Application Behaviour Module>, []}}]}.
%%% @author <Your Name>
%%% @copyright <Your Copyright System>
%%% @doc
-module(<app_behaviour>).
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
%%%===================================================================
%%% Application callbacks
%%%===================================================================
%% @private
start(_StartType, _StartArgs) ->
case <supervisor>:start_link() of
{ok, Pid} ->
{ok, Pid};
Error ->
Error
end.
%% @private
stop(_State) ->
ok.
{release,
{“<release-name>”, “<release-version>”},
{erts, “<erts-version>”},
[{<app-name>, “<app-version>”}]}.
%%% @author <author>
%%% @copyright <copyright>
%%% @doc
-module(<gen server name>).
-behaviour(gen_server).
%% API
-export([start_link/0,
get_value/1,
add_value/2]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
-define(SERVER, ?MODULE).
-record(state, []).
%%%===================================================================
%%% API
%%%===================================================================
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
get_value(Name) ->
gen_server:call(?SERVER, {get, Name}).
add_value(Name, Value) ->
gen_server:cast(?SERVER, {add, Name, Value}).
%%%===================================================================
%%% gen_server callbacks
%%%===================================================================
%% @private
init([]) ->
{ok, #state{}}.
%% @private
handle_call({get, Name}, _From, Data) ->
Reply = proplists:get_value(Name, Data),
{reply, Reply, Data}.
%% @private
handle_cast({add, Name, Value}, Data) ->
{noreply, [{Name, Value} | Data]}.
%% @private
handle_info(_Info, State) ->
{noreply, State}.
%% @private
terminate(_Reason, _State) ->
ok.
%% @private
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
{cover_enabled, true}.
{cover_print_enabled, true}.
{erl_opts, [debug_info, warnings_as_errors, inline]}.
%%% @author Eric Merritt <>
%%% @copyright (C) 2013, Eric Merritt
%%% @doc
-module(<Supervisor>).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%%===================================================================
%%% API functions
%%%===================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%%===================================================================
%%% Supervisor callbacks
%%%===================================================================
%% @private
init([]) ->
RestartStrategy = one_for_one,
MaxRestarts = 1000,
MaxSecondsBetweenRestarts = 3600,
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
Restart = permanent,
Shutdown = 2000,
Type = worker,
AChild = {'AName', {'AModule', start_link, []},
Restart, Shutdown, Type, ['AModule']},
{ok, {SupFlags, [AChild]}}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment