[erlang-questions] Help with Webmachine/Couchbeam combo
Michael McDaniel
erlangy@REDACTED
Fri Apr 23 16:30:51 CEST 2010
On Fri, Apr 23, 2010 at 09:47:13AM -0400, James Aimonetti wrote:
> I have a Webmachine app that is using Couchdb, and I'm using Couchbeam to
> retrieve and store documents and views.
>
> I start couchbeam up in a module that up to this point I called in my
> wm_app.erl (assuming I created the webmachine project with the name
> wm_app). The module called looks like this:
>
> % wm_app_couch.erl
> start() ->
> couchbeam:start(),
> Conn = couchbeam_server:start_connection_link(#couchdb_params{}),
> couchbeam_db:open_or_create(Conn, {?DB, atom_to_list(?DB)}).
>
> As I've tested storing and retrieving docs and views in the shell, on
> occasion the Db process or Conn process will die and I have to manually
> restart the processes.
>
> How do I add couchbeam, the Conn, and the Db pids to the wm_app_sup.erl
> supervisor to make sure they're automatically restarted should they die?
> I guess I'm not sure how to structure the ChildSpec for each, especially
> when the Db pid is generated using the Conn pid as an argument. Or is
> there a better, more appropriate solution.
>
________________________________________________________________
not familiar with couchbeam though if it is has behaviour gen_*
then the following will likely work.
wm_sup.erl ...
init([]) ->
...
CB = {couchbeam,
{couchbeam, start, []},
permanent, 5000, worker, dynamic} ,
Processes = [Web, ... , CB] ,
{ok, { {one_for_one, 3, 10}, Processes} }
.
~Michael
More information about the erlang-questions
mailing list