Commits

Anonymous committed 03889f3

Creation of the ehttp project.

Comments (0)

Files changed (11)

+{ './src/*', [
+	{ i, "./include" },
+	{ outdir, "./ebin" },
+	debug_info
+]}.
+
+{ './src/*/*', [
+	{ i, "./include" },
+	{ outdir, "./ebin" },
+	debug_info
+]}.
+Copyright (c) 2010, Torbjorn Tornkvist
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+include dep.inc
+
+compile: 
+	(erl -make)
+
+init: compile
+	cp src/ehttp.app.src ebin/ehttp.app 
+
+clean:
+	rm -rf ./ebin/*.beam
+

dep.inc

Empty file added.
+all:
+	(cd ..; make)
+

src/ehttp.app.src

+{application, ehttp, 
+ [
+  {description,  "ehttp - bla bla..."},
+
+  % The Module and Args used to start this application.
+  {mod, {ehttp,_app, []},
+
+  % All modules used by the application.
+  {modules,
+   [ehttp,
+    ,ehttp_app
+    ,ehttp_sup
+   ]},
+
+  % configuration parameters similar to those in the config file specified on the command line
+  {env, [
+         {platform, inets}, %% {inets|mochiweb|yaws}
+         {port, 8282},
+         {hooks_module, ehttp},
+         {session_timeout, 20},
+         {sign_key, "ferj83heu22"},
+         {www_root, "./wwwroot"}
+	]}
+ ]
+}.
+%%%-------------------------------------------------------------------
+%%% @author Torbjorn Tornkvist <tobbe@tornkvist.org>
+%%% @copyright (C) 2010, Torbjorn Tornkvist
+%%% @doc Bla bla
+%%%
+%%% @end
+%%%-------------------------------------------------------------------
+-module(ehttp).
+-export([start/0]).
+
+start() -> ok.
+   

src/ehttp_app.erl

+%%%-------------------------------------------------------------------
+%%% @author Torbjorn Tornkvist <tobbe@tornkvist.org>
+%%% @copyright (C) 2010, Torbjorn Tornkvist
+%%% @doc Bla bla
+%%%
+%%% @end
+%%%-------------------------------------------------------------------
+-module(ehttp_app).
+-export([start/2, stop/1, get_env/2, top_dir/0]).
+-behavior(application).
+
+start(_, _) -> 
+    case ehttp_sup:start_link() of
+	{ok, Pid} -> 
+	    {ok, Pid};
+	Error ->
+	    Error
+    end.
+
+
+stop(_) -> 
+    ok.
+
+get_env(Key, Default) ->
+    case application:get_env(ehttp, Key) of
+        {ok, Value} -> Value;
+        _           -> Default
+    end.
+
+top_dir() ->
+    filename:join(["/"|lists:reverse(tl(lists:reverse(string:tokens(filename:dirname(code:which(?MODULE)),"/"))))]).
+

src/ehttp_sup.erl

+%%%-------------------------------------------------------------------
+%%% @author Torbjorn Tornkvist <tobbe@tornkvist.org>
+%%% @copyright (C) 2010, Torbjorn Tornkvist
+%%% @doc Bla bla
+%%% @end
+%%%-------------------------------------------------------------------
+-module(ehttp_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+-define(SERVER, ?MODULE).
+
+%%%===================================================================
+%%% API functions
+%%%===================================================================
+
+%%--------------------------------------------------------------------
+%% @doc
+%% Starts the supervisor
+%%
+%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
+%% @end
+%%--------------------------------------------------------------------
+start_link() ->
+    supervisor:start_link({local, ?SERVER}, ?MODULE, []).
+
+%%%===================================================================
+%%% Supervisor callbacks
+%%%===================================================================
+
+%%--------------------------------------------------------------------
+%% @private
+%% @doc
+%% Whenever a supervisor is started using supervisor:start_link/[2,3],
+%% this function is called by the new process to find out about
+%% restart strategy, maximum restart frequency and child
+%% specifications.
+%%
+%% @spec init(Args) -> {ok, {SupFlags, [ChildSpec]}} |
+%%                     ignore |
+%%                     {error, Reason}
+%% @end
+%%--------------------------------------------------------------------
+server(Name, Type) ->
+    server(Name, Type, 2000).
+
+server(Name, Type, Shutdown) ->
+    {Name, {Name, start_link, []}, permanent, Shutdown, Type, [Name]}.
+
+worker(Name) -> server(Name, worker).
+
+init([]) ->
+
+%    Play = worker(play),
+
+    {ok,{{one_for_one ,0,1},
+         [%Play
+         ]}}.
+
+%%%===================================================================
+%%% Internal functions
+%%%===================================================================
+
+#!/bin/sh
+cd /home/tobbe/bin
+
+. ./dep.inc
+
+echo Starting ehttp...
+erl 	-sname ehttp 	-pa ./ebin 	-s make all 	-eval "application:start(ehttp)"