what do you think? seems to work quite nicely.
let $port := xdmp:random(65535 + 8003) + 8003 (: yes, let's force ports
above 8003 :)
return
try {
if (xdmp:http-head("http://127.0.0.1:" || $port)) then
(: try again :)
else
$port
} catch($e) {
$port
}
cheers,
Jakob.
On Fri, May 17, 2013 at 8:01 AM, Jakob Fix <[email protected]> wrote:
> Argh, that's right, I didn't think of that! All right, I'll do that then.
> Bedankt!
>
> cheers,
> Jakob.
>
>
> On Fri, May 17, 2013 at 7:37 AM, Geert Josten <[email protected]>wrote:
>
>> Hi Jakob,
>>
>>
>>
>> The port could be in use by an external (non-ML) process. You could also
>> do xdmp:http-get on the port number. Make sure to use a small timeout
>> though.. ;-)
>>
>>
>>
>> Cheers,
>>
>> Geert
>>
>>
>>
>> *Van:* [email protected] [mailto:
>> [email protected]] *Namens *Jakob Fix
>> *Verzonden:* vrijdag 17 mei 2013 7:17
>> *Aan:* MarkLogic Developer Discussion
>> *Onderwerp:* Re: [MarkLogic Dev General] how can i check whether an
>> appserver
>>
>>
>>
>> Thanks David, that does the job perfectly.
>>
>>
>> cheers,
>> Jakob.
>>
>>
>>
>> On Fri, May 17, 2013 at 12:59 AM, David Lee <[email protected]>
>> wrote:
>>
>> $port = xdmp:host-status(xdmp:host())//*:port
>>
>>
>>
>>
>> -----------------------------------------------------------------------------
>>
>> David Lee
>> Lead Engineer
>> MarkLogic Corporation
>> [email protected]
>> Phone: +1 812-482-5224
>>
>> Cell: +1 812-630-7622
>> www.marklogic.com
>>
>>
>>
>> *From:* [email protected] [mailto:
>> [email protected]] *On Behalf Of *Jakob Fix
>> *Sent:* Thursday, May 16, 2013 6:56 PM
>> *To:* General Mark Logic Developer Discussion
>> *Subject:* [MarkLogic Dev General] how can i check whether an appserver
>>
>>
>>
>> Hello,
>>
>>
>>
>> if I wanted to script the creation of an xdbc appserver and I don't
>> really care about the port number to use (so let's say I use
>> xdmp:random(65535) + 8003), how can I find out whether that port is already
>> in use by an already existing server?
>>
>>
>>
>> Basically I'm looking for a definition of the
>> local:port-number-in-use($pn) below.
>>
>> *declare function **local:get-port-number*()
>> *as xs:integer*
>> {
>> *let $pn* := *xdmp:random*(65535 + 8003)
>> *return *
>> *if* (*local:port-number-in-use*(*$pn*))
>> *then **local:get-port-number*()
>> *else $pn*
>> };
>>
>> cheers,
>> Jakob.
>>
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general