You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mahendra Kariya <ma...@gmail.com> on 2010/05/31 10:20:28 UTC

Error calling external process

Hi,

I created an external process as described on the page
http://wiki.apache.org/couchdb/ExternalProcesses
The path to python file is
/home/mahendra/Documents/external_process_couchdb.py

The contents in my /opt/apache-couchdb-0.11.0/etc/couchdb/local.ini are

[log]
;level = debug
level = info

[external]
my_process = python /home/mahendra/Documents/external_process_couchdb.py

[httpd_db_handlers]
_my__process = {couch_httpd_external, handle_external_req,<<"my_process">>}

When I open the URL http://127.0.0.1:5984/microatm/my_process (microatm is
my DB name), I get this error

{"error":"not_found","reason":"missing"}

How to solve this error?




Regards,
Mahendra Kariya

Re: Error calling external process

Posted by Mahendra Kariya <ma...@gmail.com>.
Also, when I run the following command,

/usr/local/bin/couchjs /usr/local/share/couchdb/server/main.js ["reset"]

I get this error.

/usr/local/lib/couchdb/bin/couchjs: error while loading shared libraries:
libmozjs.so: cannot open shared object file: No such file or directory

I tried

$aptitude search libmozjs

but it returned no results.

Regards,
Mahendra Kariya



On Mon, May 31, 2010 at 3:46 PM, Mahendra Kariya
<ma...@gmail.com>wrote:

> Thanks a lot. The typo was the actual error.
>
> The external application is now running. But I am getting an error, bad
> return value. I have attached the output alongwith my python source.
>
> I would also like to know some library through which it is easy to handle
> JSON requests and responses in C. Basically I have to check the JSON request
> for a *ready* flag in my external application (which will be in C), do
> some processing, and send a JSON response with a *successful* flag.
>
> Regards.
>
>
>
>
>
> On Mon, May 31, 2010 at 3:33 PM, Dave Cottlehuber <da...@muse.net.nz>wrote:
>
>> On 31 May 2010 21:31, Mahendra Kariya <ma...@gmail.com> wrote:
>> > I am running couchdb from root user. The command that I specified in
>> > my_process is working in root.
>> >
>> > CouchDB log says
>> > [info] [<0.95.0>] 127.0.0.1 - - 'GET' /microatm/my_process 404
>>
>> Try this instead:
>>
>> $ curl http://127.0.0.1:5984/microatm/_my_process
>>
>> Your httpd_db_handler URL is the first parameter in the ini file, not
>> the <<"my_process">> bit, which is a pointer for couchdb to find the
>> actual script in the [external] section.
>>
>> If you have the following diff against local.ini:
>>
>> > [external]
>> > mango = /opt/local/bin/couch_external_process.py
>> >
>> > [httpd_db_handlers]
>> > _test = {couch_httpd_external, handle_external_req, <<"mango">>}
>> >
>>
>> your URL is /microatm/_test
>> and not /microatm/mango or /microatm/_mango
>>
>> when I try an incorrect URL I get your error:
>> dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/mango
>>
>> {"error":"not_found","reason":"missing"}
>> dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/_mango
>>
>> {"error":"not_found","reason":"missing"}
>> but the correct URL is fine:
>> dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/_test
>>                                              {"qs":{}}%
>>
>> you also seem to have a typo in your local.ini file from above -
>> you've got a double _underscore_ in httpd_db_handler.
>>
>> _my__process should really be
>> _my_process
>>
>> A+
>> Dave
>>
>
>

Re: Error calling external process

Posted by Mahendra Kariya <ma...@gmail.com>.
Thanks a lot. The typo was the actual error.

The external application is now running. But I am getting an error, bad
return value. I have attached the output alongwith my python source.

I would also like to know some library through which it is easy to handle
JSON requests and responses in C. Basically I have to check the JSON request
for a *ready* flag in my external application (which will be in C), do some
processing, and send a JSON response with a *successful* flag.

Regards.




On Mon, May 31, 2010 at 3:33 PM, Dave Cottlehuber <da...@muse.net.nz> wrote:

> On 31 May 2010 21:31, Mahendra Kariya <ma...@gmail.com> wrote:
> > I am running couchdb from root user. The command that I specified in
> > my_process is working in root.
> >
> > CouchDB log says
> > [info] [<0.95.0>] 127.0.0.1 - - 'GET' /microatm/my_process 404
>
> Try this instead:
>
> $ curl http://127.0.0.1:5984/microatm/_my_process
>
> Your httpd_db_handler URL is the first parameter in the ini file, not
> the <<"my_process">> bit, which is a pointer for couchdb to find the
> actual script in the [external] section.
>
> If you have the following diff against local.ini:
>
> > [external]
> > mango = /opt/local/bin/couch_external_process.py
> >
> > [httpd_db_handlers]
> > _test = {couch_httpd_external, handle_external_req, <<"mango">>}
> >
>
> your URL is /microatm/_test
> and not /microatm/mango or /microatm/_mango
>
> when I try an incorrect URL I get your error:
> dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/mango
>
> {"error":"not_found","reason":"missing"}
> dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/_mango
>
> {"error":"not_found","reason":"missing"}
> but the correct URL is fine:
> dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/_test
>                                              {"qs":{}}%
>
> you also seem to have a typo in your local.ini file from above -
> you've got a double _underscore_ in httpd_db_handler.
>
> _my__process should really be
> _my_process
>
> A+
> Dave
>

Re: Error calling external process

Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 31 May 2010 21:31, Mahendra Kariya <ma...@gmail.com> wrote:
> I am running couchdb from root user. The command that I specified in
> my_process is working in root.
>
> CouchDB log says
> [info] [<0.95.0>] 127.0.0.1 - - 'GET' /microatm/my_process 404

Try this instead:

$ curl http://127.0.0.1:5984/microatm/_my_process

Your httpd_db_handler URL is the first parameter in the ini file, not
the <<"my_process">> bit, which is a pointer for couchdb to find the
actual script in the [external] section.

If you have the following diff against local.ini:

> [external]
> mango = /opt/local/bin/couch_external_process.py
>
> [httpd_db_handlers]
> _test = {couch_httpd_external, handle_external_req, <<"mango">>}
>

your URL is /microatm/_test
and not /microatm/mango or /microatm/_mango

when I try an incorrect URL I get your error:
dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/mango

{"error":"not_found","reason":"missing"}
dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/_mango

{"error":"not_found","reason":"missing"}
but the correct URL is fine:
dave@continuity:/Users/dave $ curl http://localhost:5984/sofa/_test
                                              {"qs":{}}%

you also seem to have a typo in your local.ini file from above -
you've got a double _underscore_ in httpd_db_handler.

_my__process should really be
_my_process

A+
Dave

Re: Error calling external process

Posted by Mahendra Kariya <ma...@gmail.com>.
I am running couchdb from root user. The command that I specified in
my_process is working in root.

CouchDB log says
[info] [<0.95.0>] 127.0.0.1 - - 'GET' /microatm/my_process 404



Regards,
Mahendra Kariya



On Mon, May 31, 2010 at 2:54 PM, Dave Cottlehuber <da...@muse.net.nz> wrote:

> On 31 May 2010 20:20, Mahendra Kariya <ma...@gmail.com> wrote:
> > Hi,
> >
> > I created an external process as described on the page
> > http://wiki.apache.org/couchdb/ExternalProcesses
> > The path to python file is
> > /home/mahendra/Documents/external_process_couchdb.py
> >
> > The contents in my /opt/apache-couchdb-0.11.0/etc/couchdb/local.ini are
> >
> > [log]
> > ;level = debug
> > level = info
> >
> > [external]
> > my_process = python /home/mahendra/Documents/external_process_couchdb.py
> >
> > [httpd_db_handlers]
> > _my__process = {couch_httpd_external,
> handle_external_req,<<"my_process">>}
> >
> > When I open the URL http://127.0.0.1:5984/microatm/my_process (microatm
> is
> > my DB name), I get this error
> >
> > {"error":"not_found","reason":"missing"}
> >
> > How to solve this error?
> >
> >
> >
> >
> > Regards,
> > Mahendra Kariya
> >
> Hi Mahendra
>
> Gut feel suggest this is permission related, or possibly path related.
> What are you seeing in your couchdb log?
>
> I'd specify an absolute path to python, and check via su that your
> script is executable and accessible by whatever user you are running
> couchdb under.
>
> cheers
> Dave
>

Re: Error calling external process

Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 31 May 2010 20:20, Mahendra Kariya <ma...@gmail.com> wrote:
> Hi,
>
> I created an external process as described on the page
> http://wiki.apache.org/couchdb/ExternalProcesses
> The path to python file is
> /home/mahendra/Documents/external_process_couchdb.py
>
> The contents in my /opt/apache-couchdb-0.11.0/etc/couchdb/local.ini are
>
> [log]
> ;level = debug
> level = info
>
> [external]
> my_process = python /home/mahendra/Documents/external_process_couchdb.py
>
> [httpd_db_handlers]
> _my__process = {couch_httpd_external, handle_external_req,<<"my_process">>}
>
> When I open the URL http://127.0.0.1:5984/microatm/my_process (microatm is
> my DB name), I get this error
>
> {"error":"not_found","reason":"missing"}
>
> How to solve this error?
>
>
>
>
> Regards,
> Mahendra Kariya
>
Hi Mahendra

Gut feel suggest this is permission related, or possibly path related.
What are you seeing in your couchdb log?

I'd specify an absolute path to python, and check via su that your
script is executable and accessible by whatever user you are running
couchdb under.

cheers
Dave