You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Antony Blakey <an...@gmail.com> on 2008/11/06 04:55:02 UTC
Simplest possible plugin/component mechanism
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/
<blah>.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)
Re: Simplest possible plugin/component mechanism
Posted by Mahesh Paolini-Subramanya <ma...@aptela.com>.
Could not agree more. Back when (way back when) we used to do
something similar to extend the NeXTStep widget set. It was usually
functional as long as I was the *only* person doing anything, but
trying to manage/maintain this across multiple users (or heck, just
myself after a 3 month gap) was insane. I eventually gave up on the
whole thing.
Also, i suspect that the security issues might be interesting, to say
the least... :-)
cheers
---
Mahesh Paolini-Subramanya
CTO, Aptela Inc.
(703.386.1500 x9100)
http://www.aptela.com
On Nov 6, 2008, at 12:08 AM, Antony Blakey wrote:
>
> On 06/11/2008, at 3:27 PM, Paul Davis wrote:
>
>> Also, not sure if this is gonna get laughed at or not, but reading
>> the
>> docs on the erl_prim_laoder, it looks like it actually wouldn't be
>> that hard to write a thing that could pull in erlang code from a
>> document. Obviously there'd be some security issues to figure out,
>> but
>> how fucking cool would it be to replicate a design doc and not only
>> have a web app, but add new functionality to the underlying server? I
>> mean, that's one hell of a plugin system if you ask me.
>
> Danger Will Robinson!
>
> In Smalltalk I run into the Subject/Object problem all the time. When
> you require your system to be stable in order to fix a problem with
> the system, you're usually SOL. Imagine deploying a plugin that
> crapped out the very mechanism used to update and deploy plugins. You
> would need a fallback mechanism for deploying plugins (e.g. ssh/rsync
> etc), in which case you might as well make the fallback mechanism the
> primary mechanism and just save yourself the grief of vicious
> circularity.
>
> Antony Blakey
> -------------
> CTO, Linkuistics Pty Ltd
> Ph: 0438 840 787
>
> There is nothing more difficult to plan, more doubtful of success, nor
> more dangerous to manage than the creation of a new order of things...
> Whenever his enemies have the ability to attack the innovator, they do
> so with the passion of partisans, while the others defend him
> sluggishly, So that the innovator and his party alike are vulnerable.
> -- Niccolo Machiavelli, 1513, The Prince.
>
>
Re: Simplest possible plugin/component mechanism
Posted by Antony Blakey <an...@gmail.com>.
On 06/11/2008, at 3:27 PM, Paul Davis wrote:
> Also, not sure if this is gonna get laughed at or not, but reading the
> docs on the erl_prim_laoder, it looks like it actually wouldn't be
> that hard to write a thing that could pull in erlang code from a
> document. Obviously there'd be some security issues to figure out, but
> how fucking cool would it be to replicate a design doc and not only
> have a web app, but add new functionality to the underlying server? I
> mean, that's one hell of a plugin system if you ask me.
Danger Will Robinson!
In Smalltalk I run into the Subject/Object problem all the time. When
you require your system to be stable in order to fix a problem with
the system, you're usually SOL. Imagine deploying a plugin that
crapped out the very mechanism used to update and deploy plugins. You
would need a fallback mechanism for deploying plugins (e.g. ssh/rsync
etc), in which case you might as well make the fallback mechanism the
primary mechanism and just save yourself the grief of vicious
circularity.
Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787
There is nothing more difficult to plan, more doubtful of success, nor
more dangerous to manage than the creation of a new order of things...
Whenever his enemies have the ability to attack the innovator, they do
so with the passion of partisans, while the others defend him
sluggishly, So that the innovator and his party alike are vulnerable.
-- Niccolo Machiavelli, 1513, The Prince.
Re: Simplest possible plugin/component mechanism
Posted by Antony Blakey <an...@gmail.com>.
On 06/11/2008, at 3:27 PM, Paul Davis wrote:
> Also, not sure if this is gonna get laughed at or not, but reading the
> docs on the erl_prim_laoder, it looks like it actually wouldn't be
> that hard to write a thing that could pull in erlang code from a
> document. Obviously there'd be some security issues to figure out, but
> how fucking cool would it be to replicate a design doc and not only
> have a web app, but add new functionality to the underlying server? I
> mean, that's one hell of a plugin system if you ask me.
Danger Will Robinson!
In Smalltalk I run into the Subject/Object problem all the time. When
you require your system to be stable in order to fix a problem with
the system, you're usually SOL. Imagine deploying a plugin that
crapped out the very mechanism used to update and deploy plugins. You
would need a fallback mechanism for deploying plugins (e.g. ssh/rsync
etc), in which case you might as well make the fallback mechanism the
primary mechanism and just save yourself the grief of vicious
circularity.
Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787
There is nothing more difficult to plan, more doubtful of success, nor
more dangerous to manage than the creation of a new order of things...
Whenever his enemies have the ability to attack the innovator, they do
so with the passion of partisans, while the others defend him
sluggishly, So that the innovator and his party alike are vulnerable.
-- Niccolo Machiavelli, 1513, The Prince.
Re: Simplest possible plugin/component mechanism
Posted by Paul Davis <pa...@gmail.com>.
Noah,
It appears that we may be able to change the module load paths via the
erl_prim_loader module. So having a config option that is has some
list of plugin paths, and then having a standardized directory layout
akin to what Antony described could be awesome.
Also, not sure if this is gonna get laughed at or not, but reading the
docs on the erl_prim_laoder, it looks like it actually wouldn't be
that hard to write a thing that could pull in erlang code from a
document. Obviously there'd be some security issues to figure out, but
how fucking cool would it be to replicate a design doc and not only
have a web app, but add new functionality to the underlying server? I
mean, that's one hell of a plugin system if you ask me.
Also, that could be completely unfeasible and I'm just too tired to notice.
Any other more coherent thoughts?
Paul
On Wed, Nov 5, 2008 at 11:29 PM, Noah Slater <ns...@apache.org> wrote:
> Hey,
>
> This is a nice idea, is there anyway to get Erlang to load modules directly
> without having to modify the path in the CouchDB script? That seems like a much
> cleaner solution to me. With this you could either:
>
> * Add a configuration option that loaded a new configuration file
> * Add new configuration files on the command line
>
> You would also need a way to load custom beam files from the configuration.
>
> Open to suggestions on this.
>
> Best,
>
> --
> Noah Slater, http://bytesexual.org/nslater
>
Re: Simplest possible plugin/component mechanism
Posted by Antony Blakey <an...@gmail.com>.
On 06/11/2008, at 2:59 PM, Noah Slater wrote:
> This is a nice idea, is there anyway to get Erlang to load modules
> directly
> without having to modify the path in the CouchDB script?
Yes, code:add_patha / code:add_pathz allow you to modify the load path
dynamically, so there's no reason why the autoload directories need to
be set in the script. You would need to ensure that the paths in the
config file could be relative.
> That seems like a much
> cleaner solution to me. With this you could either:
>
> * Add a configuration option that loaded a new configuration file
> * Add new configuration files on the command line
You could add new plugins or plugin directories on the command line.
I was looking for a mechanism that didn't require any code.
Antony Blakey
--------------------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787
Always have a vision. Why spend your life making other people’s dreams?
-- Orson Welles (1915-1985)
Re: Simplest possible plugin/component mechanism
Posted by Paul Davis <pa...@gmail.com>.
Noah,
It appears that we may be able to change the module load paths via the
erl_prim_loader module. So having a config option that is has some
list of plugin paths, and then having a standardized directory layout
akin to what Antony described could be awesome.
Also, not sure if this is gonna get laughed at or not, but reading the
docs on the erl_prim_laoder, it looks like it actually wouldn't be
that hard to write a thing that could pull in erlang code from a
document. Obviously there'd be some security issues to figure out, but
how fucking cool would it be to replicate a design doc and not only
have a web app, but add new functionality to the underlying server? I
mean, that's one hell of a plugin system if you ask me.
Also, that could be completely unfeasible and I'm just too tired to notice.
Any other more coherent thoughts?
Paul
On Wed, Nov 5, 2008 at 11:29 PM, Noah Slater <ns...@apache.org> wrote:
> Hey,
>
> This is a nice idea, is there anyway to get Erlang to load modules directly
> without having to modify the path in the CouchDB script? That seems like a much
> cleaner solution to me. With this you could either:
>
> * Add a configuration option that loaded a new configuration file
> * Add new configuration files on the command line
>
> You would also need a way to load custom beam files from the configuration.
>
> Open to suggestions on this.
>
> Best,
>
> --
> Noah Slater, http://bytesexual.org/nslater
>
Re: Simplest possible plugin/component mechanism
Posted by Noah Slater <ns...@apache.org>.
Hey,
This is a nice idea, is there anyway to get Erlang to load modules directly
without having to modify the path in the CouchDB script? That seems like a much
cleaner solution to me. With this you could either:
* Add a configuration option that loaded a new configuration file
* Add new configuration files on the command line
You would also need a way to load custom beam files from the configuration.
Open to suggestions on this.
Best,
--
Noah Slater, http://bytesexual.org/nslater
Re: Simplest possible plugin/component mechanism
Posted by Noah Slater <ns...@apache.org>.
Hey,
This is a nice idea, is there anyway to get Erlang to load modules directly
without having to modify the path in the CouchDB script? That seems like a much
cleaner solution to me. With this you could either:
* Add a configuration option that loaded a new configuration file
* Add new configuration files on the command line
You would also need a way to load custom beam files from the configuration.
Open to suggestions on this.
Best,
--
Noah Slater, http://bytesexual.org/nslater