You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Benoit Chesneau (JIRA)" <ji...@apache.org> on 2010/06/25 17:08:52 UTC
[jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
[ https://issues.apache.org/jira/browse/COUCHDB-393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benoit Chesneau updated COUCHDB-393:
------------------------------------
Attachment: couch_uri.patch
Here is the patch. It take couch.uri path from the configuration file . by default it's in %localstatelibdir%/couch.uri .
It save the uti http://IP:PORT/ on one line when couchdb start. If it's ok for you I will be happy to commit it today.
> Cannot discover currently running http port if ini file specifies port 0
> ------------------------------------------------------------------------
>
> Key: COUCHDB-393
> URL: https://issues.apache.org/jira/browse/COUCHDB-393
> Project: CouchDB
> Issue Type: Improvement
> Components: HTTP Interface
> Affects Versions: 0.9
> Environment: Ubuntu 9.04
> Reporter: Stuart Langridge
> Assignee: Noah Slater
> Priority: Blocker
> Fix For: 0.12
>
> Attachments: couch_uri.patch, couchctl.patch
>
>
> It is currently not possible, if the ini file specifies port 0 as the http port (so that the OS chooses a random port) to discover which port the OS actually chose.
> It would be nice if the currently running port was made available in the statusline output (couchdb -s), but a log statement would be adequate; some way that an external script can discover which port a running CouchDB is listening on.
> Edited discussion from #couchdb:
> <bitdiddle> aquarius: well at a glance it appears couch_http passes the 0 to mochiweb_http which passes it to the mochiweb_socket_server, which passes it to gen_tcp, an erlang module that lets the underlying OS assign it. mochiweb_socket_server then grabs that port and stores it. It has a get method to retrieve properties but that needs to be exposed to mochiweb_http so it would take a little work to do it. It's probably a JIRA ticket, unless someone else sees a quicker approach
> <davisp> bitdiddle: you got that far and didn't find it?
> <aquarius> davisp: is there a better way to find the port?
> <davisp> oh, is that not the bind port?
> I was just thinking a log statement
> <aquarius> davisp: the problem is if you specify 0 as the bind port (so the OS chooses a port), how do you find out what was chosen?
> <davisp> aquarius: you have to look at the port returned by the socket
> aquarius: in other words, CouchDB was never written to do that
> <davisp> AFAIK
> <bitdiddle> davisp: I found it, just needs some work to expose it
> <davisp> aquarius: and by do that, I mean, we never put in a statement to log that
> <bitdiddle> mochiweb_http is the module that needs to bubble it up
> <aquarius> davisp: I don't really mind whether it's a log statement or it's exposed to couchdb -s (the latter seems tidier to me, but whichever), I just want to be able to start couch on port 0 and then later find out which port got chosen :)
> <davisp> aquarius: for the time being you can use something like netstat or lsof, but we'll get a log statement in there or something
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jun 25, 2010 at 7:40 PM, Noah Slater <ns...@tumbolia.org> wrote:
> 1.0 should be relatively stable though. So if we're planning to replace the patch with another patch that works differently, is that a good idea. Or do you think both things could live side by side without any trouble?
>
They could live together, but it may be redundant at the end. Is this a problem
If we have some time I could work on another solution. For now I fail
though to find a way to get final port from couch in the shell script.
The only simple way I see for now is to name the CouchDB node and then
call some specific function with erlang that return the correct
information. The list of nodes could be get via erlang too. But do we
want to name the nodes ? (via -sname or such) .
If we don't name the nodes, there may be a way to do it via os pids,
but I don't know it yet.
- benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running http port if ini file specifies port 0
Posted by Noah Slater <ns...@tumbolia.org>.
1.0 should be relatively stable though. So if we're planning to replace the patch with another patch that works differently, is that a good idea. Or do you think both things could live side by side without any trouble?
On 25 Jun 2010, at 18:20, Benoit Chesneau wrote:
> On Fri, Jun 25, 2010 at 7:02 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Fri, Jun 25, 2010 at 6:36 PM, Noah Slater <ns...@tumbolia.org> wrote:
>>> Anyone used screen?
>>>
>>> When you do "screen -l" you get a list of running screens.
>>>
>>> "couchdb -s" could do something similar.
>>>
>>> You could then do "couchdb -s PID" to get the status of that instance, with URL.
>>>
>>> Thoughts?
>>>
>>
>> That can be done by parsing result of ps I think. Is there a way once
>> we have the pid to get the localstatelibdir of this pid ? So we could
>> read the uri or such ?
>>
>> There maybe a way to do it via erlang but I don't know one actually .
>>
>> if we could do a remote call on one sname we could get the port but we
>> don't set the sname actually.
>>
>> - benoit
>>
>> - benoit
>>
>
> Anyway couldn't it be done in a future version ? I don't want to
> introduce some extra complexity for a 1.0. Really would like this
> patch appear in 1.0 so it can help to port couchdbdesktop or any
> alternative to others OS.
>
> - benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jun 25, 2010 at 7:02 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Fri, Jun 25, 2010 at 6:36 PM, Noah Slater <ns...@tumbolia.org> wrote:
>> Anyone used screen?
>>
>> When you do "screen -l" you get a list of running screens.
>>
>> "couchdb -s" could do something similar.
>>
>> You could then do "couchdb -s PID" to get the status of that instance, with URL.
>>
>> Thoughts?
>>
>
> That can be done by parsing result of ps I think. Is there a way once
> we have the pid to get the localstatelibdir of this pid ? So we could
> read the uri or such ?
>
> There maybe a way to do it via erlang but I don't know one actually .
>
> if we could do a remote call on one sname we could get the port but we
> don't set the sname actually.
>
> - benoit
>
> - benoit
>
Anyway couldn't it be done in a future version ? I don't want to
introduce some extra complexity for a 1.0. Really would like this
patch appear in 1.0 so it can help to port couchdbdesktop or any
alternative to others OS.
- benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jun 25, 2010 at 6:36 PM, Noah Slater <ns...@tumbolia.org> wrote:
> Anyone used screen?
>
> When you do "screen -l" you get a list of running screens.
>
> "couchdb -s" could do something similar.
>
> You could then do "couchdb -s PID" to get the status of that instance, with URL.
>
> Thoughts?
>
That can be done by parsing result of ps I think. Is there a way once
we have the pid to get the localstatelibdir of this pid ? So we could
read the uri or such ?
There maybe a way to do it via erlang but I don't know one actually .
if we could do a remote call on one sname we could get the port but we
don't set the sname actually.
- benoit
- benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running http port if ini file specifies port 0
Posted by Noah Slater <ns...@tumbolia.org>.
Anyone used screen?
When you do "screen -l" you get a list of running screens.
"couchdb -s" could do something similar.
You could then do "couchdb -s PID" to get the status of that instance, with URL.
Thoughts?
On 25 Jun 2010, at 17:35, Randall Leeds wrote:
> On Fri, Jun 25, 2010 at 11:01, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Fri, Jun 25, 2010 at 5:47 PM, Noah Slater <ns...@tumbolia.org> wrote:
>>> No, what I meant is that this patch should add that functionality. Hehe.
>>>
>> Mmm doable by parsing this file, though it will require to know where
>> the file is, which could be difficult. I wonder how -s works when
>> using the same installed base but with different ini at startup by the
>> way.
>
> You can make -s work by using different pid files for each instance.
> I'm not sure how to make it know the port.
>
> -Randall
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
Posted by Randall Leeds <ra...@gmail.com>.
On Fri, Jun 25, 2010 at 11:01, Benoit Chesneau <bc...@gmail.com> wrote:
> On Fri, Jun 25, 2010 at 5:47 PM, Noah Slater <ns...@tumbolia.org> wrote:
>> No, what I meant is that this patch should add that functionality. Hehe.
>>
> Mmm doable by parsing this file, though it will require to know where
> the file is, which could be difficult. I wonder how -s works when
> using the same installed base but with different ini at startup by the
> way.
You can make -s work by using different pid files for each instance.
I'm not sure how to make it know the port.
-Randall
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jun 25, 2010 at 5:47 PM, Noah Slater <ns...@tumbolia.org> wrote:
> No, what I meant is that this patch should add that functionality. Hehe.
>
Mmm doable by parsing this file, though it will require to know where
the file is, which could be difficult. I wonder how -s works when
using the same installed base but with different ini at startup by the
way.
I'm not sure it works in this case :) Imo I would keep the simple way.
- benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running http port if ini file specifies port 0
Posted by Noah Slater <ns...@tumbolia.org>.
No, what I meant is that this patch should add that functionality. Hehe.
On 25 Jun 2010, at 16:39, Benoit Chesneau wrote:
> On Fri, Jun 25, 2010 at 5:20 PM, Noah Slater <ns...@tumbolia.org> wrote:
>> `couchdb -s` should probably report the URL
>>
> mmm I read the source well, it doesn't. It just give the status of
> CouchDB : pid + if running or not. Also you can't know the port before
> CouchDB is launched if port = 0 which is the way some app are
> launching couchdb like desktop-couch.
>
> - Benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running
http port if ini file specifies port 0
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jun 25, 2010 at 5:20 PM, Noah Slater <ns...@tumbolia.org> wrote:
> `couchdb -s` should probably report the URL
>
mmm I read the source well, it doesn't. It just give the status of
CouchDB : pid + if running or not. Also you can't know the port before
CouchDB is launched if port = 0 which is the way some app are
launching couchdb like desktop-couch.
- Benoit
Re: [jira] Updated: (COUCHDB-393) Cannot discover currently running http port if ini file specifies port 0
Posted by Noah Slater <ns...@tumbolia.org>.
`couchdb -s` should probably report the URL
On 25 Jun 2010, at 16:08, Benoit Chesneau (JIRA) wrote:
>
> [ https://issues.apache.org/jira/browse/COUCHDB-393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Benoit Chesneau updated COUCHDB-393:
> ------------------------------------
>
> Attachment: couch_uri.patch
>
> Here is the patch. It take couch.uri path from the configuration file . by default it's in %localstatelibdir%/couch.uri .
>
> It save the uti http://IP:PORT/ on one line when couchdb start. If it's ok for you I will be happy to commit it today.
>
>> Cannot discover currently running http port if ini file specifies port 0
>> ------------------------------------------------------------------------
>>
>> Key: COUCHDB-393
>> URL: https://issues.apache.org/jira/browse/COUCHDB-393
>> Project: CouchDB
>> Issue Type: Improvement
>> Components: HTTP Interface
>> Affects Versions: 0.9
>> Environment: Ubuntu 9.04
>> Reporter: Stuart Langridge
>> Assignee: Noah Slater
>> Priority: Blocker
>> Fix For: 0.12
>>
>> Attachments: couch_uri.patch, couchctl.patch
>>
>>
>> It is currently not possible, if the ini file specifies port 0 as the http port (so that the OS chooses a random port) to discover which port the OS actually chose.
>> It would be nice if the currently running port was made available in the statusline output (couchdb -s), but a log statement would be adequate; some way that an external script can discover which port a running CouchDB is listening on.
>> Edited discussion from #couchdb:
>> <bitdiddle> aquarius: well at a glance it appears couch_http passes the 0 to mochiweb_http which passes it to the mochiweb_socket_server, which passes it to gen_tcp, an erlang module that lets the underlying OS assign it. mochiweb_socket_server then grabs that port and stores it. It has a get method to retrieve properties but that needs to be exposed to mochiweb_http so it would take a little work to do it. It's probably a JIRA ticket, unless someone else sees a quicker approach
>> <davisp> bitdiddle: you got that far and didn't find it?
>> <aquarius> davisp: is there a better way to find the port?
>> <davisp> oh, is that not the bind port?
>> I was just thinking a log statement
>> <aquarius> davisp: the problem is if you specify 0 as the bind port (so the OS chooses a port), how do you find out what was chosen?
>> <davisp> aquarius: you have to look at the port returned by the socket
>> aquarius: in other words, CouchDB was never written to do that
>> <davisp> AFAIK
>> <bitdiddle> davisp: I found it, just needs some work to expose it
>> <davisp> aquarius: and by do that, I mean, we never put in a statement to log that
>> <bitdiddle> mochiweb_http is the module that needs to bubble it up
>> <aquarius> davisp: I don't really mind whether it's a log statement or it's exposed to couchdb -s (the latter seems tidier to me, but whichever), I just want to be able to start couch on port 0 and then later find out which port got chosen :)
>> <davisp> aquarius: for the time being you can use something like netstat or lsof, but we'll get a log statement in there or something
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>