This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Newson
committed
Feb 19, 2011
1 parent
8293f94
commit a1185e4
Showing
19 changed files
with
207 additions
and
858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ ebin | |
doc | ||
.eunit | ||
*~ | ||
deps | ||
priv/log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Project Skeleton for the monic app. | ||
|
||
You should find in this directory: | ||
|
||
README : this file | ||
Makefile : simple make commands | ||
rebar : the Rebar build tool for Erlang applications | ||
rebar.config : configuration for Rebar | ||
start.sh : simple startup script for running monic | ||
/ebin | ||
/monic.app : the Erlang app specification | ||
/src | ||
/monic_app.erl : base module for the Erlang application | ||
/monic_sup.erl : OTP supervisor for the application | ||
/monic_resource.erl : a simple example Webmachine resource | ||
/priv | ||
/dispatch.conf : the Webmachine URL-dispatching table | ||
/www : a convenient place to put your static web content | ||
|
||
You probably want to do one of a couple of things at this point: | ||
|
||
0. Build the skeleton application: | ||
$ make | ||
- or - | ||
$ ./rebar compile | ||
|
||
1. Start up the skeleton application: | ||
$ ./start.sh | ||
|
||
2. Change the basic application: | ||
edit src/monic_resource.erl | ||
|
||
3. Add some new resources: | ||
edit src/YOUR_NEW_RESOURCE.erl | ||
edit priv/dispatch.conf |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%%-*- mode: erlang -*- | ||
|
||
{[file], monic_file_manager, []}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%%-*- mode: erlang -*- | ||
|
||
{deps, [{webmachine, "1.8.*", {git, "git://github.com/basho/webmachine", "HEAD"}}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,17 @@ | ||
% Copyright 2011 Cloudant | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
% use this file except in compliance with the License. You may obtain a copy of | ||
% the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
% License for the specific language governing permissions and limitations under | ||
% the License. | ||
|
||
%%-*- mode: erlang -*- | ||
{application, monic, | ||
[ | ||
{description, "Contiguous attachment storage system"}, | ||
{vsn, git}, | ||
{description, "monic"}, | ||
{vsn, "1"}, | ||
{modules, []}, | ||
{registered, []}, | ||
{applications, [ | ||
kernel, | ||
stdlib, | ||
crypto | ||
crypto, | ||
mochiweb, | ||
webmachine | ||
]}, | ||
{mod, { monic_app, []}}, | ||
{env, [ | ||
{root_dir,"tmp"}, | ||
{concurrency, 10} | ||
]} | ||
{env, []} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,45 @@ | ||
% Copyright 2011 Cloudant | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
% use this file except in compliance with the License. You may obtain a copy of | ||
% the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
% License for the specific language governing permissions and limitations under | ||
% the License. | ||
%% @author author <author@example.com> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc monic startup code | ||
|
||
-module(monic). | ||
-export([start/0, stop/0]). | ||
-export([write/2, read/2, read/3, read/4, delete/2]). | ||
-include("monic.hrl"). | ||
-author('author <author@example.com>'). | ||
-export([start/0, start_link/0, stop/0]). | ||
|
||
ensure_started(App) -> | ||
case application:start(App) of | ||
ok -> | ||
ok; | ||
{error, {already_started, App}} -> | ||
ok | ||
end. | ||
|
||
%% @spec start_link() -> {ok,Pid::pid()} | ||
%% @doc Starts the app for inclusion in a supervisor tree | ||
start_link() -> | ||
ensure_started(crypto), | ||
ensure_started(mochiweb), | ||
application:set_env(webmachine, webmachine_logger_module, | ||
webmachine_logger), | ||
ensure_started(webmachine), | ||
monic_sup:start_link(). | ||
|
||
%% @spec start() -> ok | ||
%% @doc Start the monic server. | ||
start() -> | ||
ensure_started(crypto), | ||
ensure_started(mochiweb), | ||
application:set_env(webmachine, webmachine_logger_module, | ||
webmachine_logger), | ||
ensure_started(webmachine), | ||
application:start(monic). | ||
|
||
%% @spec stop() -> ok | ||
%% @doc Stop the monic server. | ||
stop() -> | ||
application:stop(monic). | ||
|
||
write(Group, Bin) when is_binary(Bin) -> | ||
call(Group, {write, Bin}); | ||
write(Group, Fun) when is_function(Fun) -> | ||
call(Group, {write, Fun}). | ||
|
||
read(Group, #handle{}=Handle) -> | ||
call(Group, {read, Handle}). | ||
|
||
read(Group, #handle{}=Handle, Fun) when is_function(Fun) -> | ||
call(Group, {read, Handle, Fun}). | ||
|
||
read(Group, #handle{}=Handle, Ranges, Fun) when is_function(Fun) -> | ||
call(Group, {read, Handle, Ranges, Fun}). | ||
|
||
delete(Group, #handle{}=Handle) -> | ||
call(Group, {delete, Handle}). | ||
|
||
call(Group, Msg) -> | ||
gen_server:call(group(Group), Msg, infinity). | ||
|
||
group(Group) -> | ||
Spec = { | ||
Group, | ||
{gen_server, start_link, [monic_group, [Group], []]}, | ||
temporary, 1, worker, [?MODULE] | ||
}, | ||
%% relevant parts of couch_rep.erl below. | ||
case supervisor:start_child(monic_sup, Spec) of | ||
{ok, Pid} -> | ||
Pid; | ||
{error, {already_started, Pid}} -> | ||
Pid; | ||
{error, already_present} -> | ||
case supervisor:restart_child(monic_sup, Group) of | ||
{ok, Pid} -> | ||
Pid; | ||
{error, running} -> | ||
{error, {already_started, Pid}} = | ||
supervisor:start_child(monic_sup, Spec), | ||
Pid | ||
end | ||
end. | ||
Res = application:stop(monic), | ||
application:stop(webmachine), | ||
application:stop(mochiweb), | ||
application:stop(crypto), | ||
Res. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
% Copyright 2011 Cloudant | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
% use this file except in compliance with the License. You may obtain a copy of | ||
% the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
% License for the specific language governing permissions and limitations under | ||
% the License. | ||
%% @author author <author@example.com> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc Callbacks for the monic application. | ||
|
||
-module(monic_app). | ||
-author('author <author@example.com>'). | ||
|
||
-behaviour(application). | ||
-export([start/2,stop/1]). | ||
|
||
%% Application callbacks | ||
-export([start/2, stop/1]). | ||
|
||
%% =================================================================== | ||
%% Application callbacks | ||
%% =================================================================== | ||
|
||
start(_StartType, _StartArgs) -> | ||
%% @spec start(_Type, _StartArgs) -> ServerRet | ||
%% @doc application start callback for monic. | ||
start(_Type, _StartArgs) -> | ||
monic_sup:start_link(). | ||
|
||
%% @spec stop(_State) -> ServerRet | ||
%% @doc application stop callback for monic. | ||
stop(_State) -> | ||
ok. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.