From couchdb-dev-return-1193-apmail-incubator-couchdb-dev-archive=incubator.apache.org@incubator.apache.org Thu Nov 06 03:55:46 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-dev-archive@locus.apache.org Received: (qmail 6638 invoked from network); 6 Nov 2008 03:55:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2008 03:55:46 -0000 Received: (qmail 14716 invoked by uid 500); 6 Nov 2008 03:55:46 -0000 Delivered-To: apmail-incubator-couchdb-dev-archive@incubator.apache.org Received: (qmail 14635 invoked by uid 500); 6 Nov 2008 03:55:46 -0000 Mailing-List: contact couchdb-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-dev@incubator.apache.org Received: (qmail 14614 invoked by uid 99); 6 Nov 2008 03:55:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2008 19:55:46 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of antony.blakey@gmail.com designates 74.125.92.146 as permitted sender) Received: from [74.125.92.146] (HELO qw-out-1920.google.com) (74.125.92.146) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Nov 2008 03:54:29 +0000 Received: by qw-out-1920.google.com with SMTP id 4so269074qwk.54 for ; Wed, 05 Nov 2008 19:55:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=z4GH5d0gTTXAjpcgIY6qU8yoMEY52C4buS5nsiqDSU4=; b=m0sTxJ+lOSnWZNBIvjiLUnhtGTLTIDUESM6EnKP1WwrH0XXggZBSEJcCYmSS752ty0 1Ni/H7rSuyk/VRCjaE1gw98L8Kor2U8Ox2w3S0SgzP7pdJdbvhqjdImz6R5iBN+rFR0u beP6YUJJZqduBnKaMqYaShK6fYA0nez0o4C88= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=Sd2cdfcrVkLNu9LdsrvKzj+SGRBjC2vOogNrzr+6dXOj8ntW1l2LZgVB2KKB2+i4bE WoFi83VIz0dAUXZSoUuny4pGllmnb4oaLdBhFyEDGn2Jdp+JJI/TJXO3PW4aC0r97P/C BbDlLnRmQWG0FRWjS4y5dBTAU9CnIfhxoZwAY= Received: by 10.214.181.20 with SMTP id d20mr1711378qaf.378.1225943709091; Wed, 05 Nov 2008 19:55:09 -0800 (PST) Received: from ?192.168.0.16? (ppp121-45-224-135.lns10.adl6.internode.on.net [121.45.224.135]) by mx.google.com with ESMTPS id 7sm930165ywo.7.2008.11.05.19.55.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 05 Nov 2008 19:55:08 -0800 (PST) Message-Id: <39E37E59-AA38-4BCE-BC54-296B5C92EACC@gmail.com> From: Antony Blakey To: couchdb-dev@incubator.apache.org, couchdb-user@incubator.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Simplest possible plugin/component mechanism Date: Thu, 6 Nov 2008 14:25:02 +1030 References: <4C915D97-E639-4FEC-BCB4-F8E6B42FE7AD@gmail.com> X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org As part of my efforts to write an erlang plugin I did the following to the bin/couchdb script: 1. Add the following near the head of the file: PLUGINS_DIRECTORY=/usr/local/etc/couchdb/plugins PLUGIN_INI_FILES= PLUGIN_ERLANG_PATHS= for plugin in $PLUGINS_DIRECTORY/*; do if test -d $plugin/ebin; then PLUGIN_ERLANG_PATHS="$PLUGIN_ERLANG_PATHS $plugin/ebin"; fi if test -f $plugin/config.ini; then PLUGIN_INI_FILES="$PLUGIN_INI_FILES $plugin/config.ini"; fi done 2. Modify the code that accumulates the ini files: if test -n "$INI_FILES"; then ini_files="$PLUGIN_INI_FILES $INI_FILES" else ini_files="$DEFAULT_INI_FILE $LOCAL_INI_FILE $PLUGIN_INI_FILES" fi 3. Modify the code that starts couchdb: command="`/opt/local/bin/icu-config --invoke` \ /opt/local/bin/erl $interactive_option -smp auto -sasl errlog_type error +K true \ -pa /usr/local/lib/couchdb/erlang/lib/couch-0.9.0a-incubating/ ebin \ /usr/local/lib/couchdb/erlang/lib/mochiweb-r82/ebin \ $PLUGIN_ERLANG_PATHS \ -eval \"application:load(inets)\" \ -eval \"application:load(crypto)\" \ -eval \"application:load(couch)\" \ -eval \"crypto:start()\" \ -eval \"inets:start()\" \ -eval \"couch_server:start([$start_arguments]), receive done - > done end.\" " Now I can drop components into /usr/local/etc/couchdb/plugins: /usr/local/etc/plugins/ 00test/ config.ini ebin/ .beam Something like this would seem to be the simplest possible mechanism that allows separately packaged components. Antony Blakey -------------------------- CTO, Linkuistics Pty Ltd Ph: 0438 840 787 What can be done with fewer [assumptions] is done in vain with more -- William of Ockham (ca. 1285-1349)