Thanks for the insights. I've got it working as I would like using
this little nodejs wrapper:

#!/usr/bin/env node

var child = require('child_process');
var lucene = child.spawn('/usr/local/divebox/sbin/couchdb-lucene/bin/run');
lucene.stdout.pipe( process.stdout, { end: false } );
process.stdin.resume();
process.stdin.pipe( lucene.stdin, { end: false } );
process.stdin.on( 'close', function()
{
        lucene.kill('SIGHUP');
} );
lucene.on('exit', function (code) {
   process.exit(code);
});

And then point to the wrapper in the configuration:

[os_daemons]
couchdb_lucene =
/usr/local/divebox/sbin/couchdb-lucene/bin/node-lucene-daemon -with

Thanks for the help!

2012/9/2 Robert Newson <[email protected]>:
>
> couchdb-lucene is a standalone service and does not usually start or stop 
> with couchdb. As Paul notes, processes daemonized by couchdb are required to 
> exit when stdin is closed, which newer versions of couchdb-lucene do not do. 
> If the os_daemons feature sent a kill signal, then couchdb-lucene would 
> indeed exit as expected.
>
> In summary, couchdb-lucene is a normal service and does not honor the couchdb 
> external handlers model.
>
> B.
>
> On 2 Sep 2012, at 22:00, Paul Davis wrote:
>
>> couchdb-lucene probably doesn't listen to its stdio file descriptors
>> to know when to shut down (or alternatively, monitor its parent
>> process ID).
>>
>> On Sun, Sep 2, 2012 at 2:57 PM, muji <[email protected]> wrote:
>>> I've just started the process of integrating couchdb-lucene with my
>>> project and thought that the lucene server would be a good candidate
>>> for integrating using the [os_daemons] functionality.
>>>
>>> My configuration looks like:
>>>
>>> [os_daemons]
>>> couchdb_lucene = /usr/local/divebox/sbin/couchdb-lucene/bin/run -with
>>>
>>> couch dutifully starts the process upon start up and monitors the
>>> process while it is running but when I shut couch down the
>>> couchdb-lucene java process is still running.
>>>
>>> Is this expected behaviour?
>>>
>>> This behaviour of course leaves rogue java processes running after
>>> couch server restarts (the new processes as they cannot bind to the
>>> lucene server port). It is arguable that the couchdb-lucene program
>>> should quit with a non-zero exit status when the server port is
>>> already in use, but then the question is whether couchdb would
>>> continue to monitor the os_daemon process started previously? I guess
>>> not as couch would not attempt to start a new process if it detected
>>> the one from a previously running couch.
>>>
>>> Personally, I think the [os_daemons] functionality should also
>>> terminate the process at shutdown, but then I guess this would need to
>>> be optional for use cases where the daemon is persistent when couch is
>>> shutdown but couch is still used to monitor the process while it is
>>> up.
>>>
>>> Any thoughts/advice much appreciated.
>>>
>>> --
>>> mischa (aka muji).
>



-- 
mischa (aka muji).

Reply via email to