couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Smith <jason.h.sm...@gmail.com>
Subject Re: git commit: updated refs/heads/master to a653e8d
Date Tue, 06 Aug 2013 10:14:17 GMT
Hi, Alexander. CouchDB re-exports its environment to os_daemons, so
FOO="bar" couchdb would already pass $FOO through.

However, if CouchDB wants to build up new environment variables for a
specific daemon, it can now simply call start_port/2 instead. I pulled this
small patch from my nodejs branch, where it was useful.

    % Example
    Port = couch_config:get("httpd", "port"),
    Env = [ {"COUCHDB_PORT", Port} ]
    start_port(Command, Env)

And now the subprocess will know which port to access CouchDB. It is not a
great example, because you can already query the config via a standard i/o
protocol, but the idea is sending arbitrary initialization values to
os_daemons. For example, at Iris Couch, we use this to tell a daemon
details about the data center and account information.


On Tue, Aug 6, 2013 at 5:03 PM, Alexander Shorin <kxepal@gmail.com> wrote:

> Hi Jason,
>
> What is the use case? It's about sharing CouchDB's local environ
> variables with os_daemons? Like:
>
> FOO="bar" couchdb -b
>
> and FOO will be available for os_daemons?
>
> --
> ,,,^..^,,,
>
>
> On Tue, Aug 6, 2013 at 1:57 PM,  <jhs@apache.org> wrote:
> > Updated Branches:
> >   refs/heads/master 91b84219f -> a653e8d0f
> >
> >
> > Support providing environment variables to os_daemon subprocesses
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a653e8d0
> > Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a653e8d0
> > Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a653e8d0
> >
> > Branch: refs/heads/master
> > Commit: a653e8d0fcf0e8560af99b549c4ab9ed42a924e1
> > Parents: 91b8421
> > Author: Jason Smith (work) <jhs@apache.org>
> > Authored: Tue Aug 6 09:56:21 2013 +0000
> > Committer: Jason Smith (work) <jhs@apache.org>
> > Committed: Tue Aug 6 09:56:46 2013 +0000
> >
> > ----------------------------------------------------------------------
> >  src/couchdb/couch_os_daemons.erl | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/a653e8d0/src/couchdb/couch_os_daemons.erl
> > ----------------------------------------------------------------------
> > diff --git a/src/couchdb/couch_os_daemons.erl
> b/src/couchdb/couch_os_daemons.erl
> > index 9a912c4..cac031a 100644
> > --- a/src/couchdb/couch_os_daemons.erl
> > +++ b/src/couchdb/couch_os_daemons.erl
> > @@ -193,9 +193,19 @@ code_change(_OldVsn, State, _Extra) ->
> >  %
> >
> >  start_port(Command) ->
> > +    start_port(Command, []).
> > +
> > +start_port(Command, EnvPairs) ->
> >      PrivDir = couch_util:priv_dir(),
> >      Spawnkiller = filename:join(PrivDir, "couchspawnkillable"),
> > -    Port = open_port({spawn, Spawnkiller ++ " " ++ Command},
> ?PORT_OPTIONS),
> > +    Opts = case lists:keytake(env, 1, ?PORT_OPTIONS) of
> > +        false ->
> > +            ?PORT_OPTIONS ++ [ {env,EnvPairs} ];
> > +        {value, {env,OldPairs}, SubOpts} ->
> > +            AllPairs = lists:keymerge(1, EnvPairs, OldPairs),
> > +            SubOpts ++ [ {env,AllPairs} ]
> > +    end,
> > +    Port = open_port({spawn, Spawnkiller ++ " " ++ Command}, Opts),
> >      {ok, Port}.
> >
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message