Re: [nodejs] Most efficient way of piping HTTP body through a tunneling proxy

2012-08-03 Thread Diogo Resende
I'm not sure why you don't use .pipe().. you don't need to buffer all the 
request before sending it. The headers should have a content-length so your 
endpoint will know about it. Just send the data directly to the other end 
instead of buffering.

-- 
Diogo Resende


On Monday, July 30, 2012 at 22:40 , axs wrote:

> Thank you, Mikeal. I use request quite a bit in my projects, and it's great. 
> However, I won't be using request for this project, because I need to write 
> this one at the transport layer. Eventually I will be redirecting various 
> requests to other servers and examining data at the transport layer. I just 
> need to make this barebones version function and then branch from it. Any 
> ideas on how to pipe the request into the socket? 
> 
> I thought of listening to the 'connection' event on the proxy server, and 
> piping the socket into the tunnel. But this won't differentiate between http 
> and https requests without parsing the request header, which I'm not sure how 
> to do.
> 
> Regards,
> Alex
> 
> On Monday, July 30, 2012 5:21:04 PM UTC-4, Mikeal Rogers wrote:
> > request does all of this, including SSL tunneling.
> > 
> > req.pipe(request(req.url, {proxy:'https://site.com'})).pipe(resp)
> > 
> > -Mikeal
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com 
> (mailto:nodejs@googlegroups.com)
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com 
> (mailto:nodejs+unsubscr...@googlegroups.com)
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Node.js under OSX

2012-08-03 Thread kyogron
Hi,

I have now switched from GNU/Linux to Mac OSX.

I am quite uncertain about managing dev-packages but I also may have to say 
that I am archlinux spoilt.

However I finally managed installing node, mongodb and redis through 
Homebrew.
As editor I use sublime text2. 

I would now like to know if choosing Homebrew over MacPorts was a good 
decision and if there are other things to mention about using node under OSX

In the meantime I will try to use automator to start mongodb and redis on 
boot up.

Best Regards,
Bodo

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Most efficient way of piping HTTP body through a tunneling proxy

2012-08-03 Thread Dominic Tarr
@john I applaud your efforts for FREE WIFI!

does the firewall permit http pipelining?

also, have you heard of dnstunneling? http://dnstunnel.de/

with a little bit more work you could make your http-tunnel into a
reliable stream
that maintained stream semantics over disconnects.

On Fri, Aug 3, 2012 at 10:37 AM, Diogo Resende  wrote:
> I'm not sure why you don't use .pipe().. you don't need to buffer all the
> request before sending it. The headers should have a content-length so your
> endpoint will know about it. Just send the data directly to the other end
> instead of buffering.
>
> --
> Diogo Resende
>
> On Monday, July 30, 2012 at 22:40 , axs wrote:
>
> Thank you, Mikeal. I use request quite a bit in my projects, and it's great.
> However, I won't be using request for this project, because I need to write
> this one at the transport layer. Eventually I will be redirecting various
> requests to other servers and examining data at the transport layer. I just
> need to make this barebones version function and then branch from it. Any
> ideas on how to pipe the request into the socket?
>
> I thought of listening to the 'connection' event on the proxy server, and
> piping the socket into the tunnel. But this won't differentiate between http
> and https requests without parsing the request header, which I'm not sure
> how to do.
>
> Regards,
> Alex
>
> On Monday, July 30, 2012 5:21:04 PM UTC-4, Mikeal Rogers wrote:
>
> request does all of this, including SSL tunneling.
>
> req.pipe(request(req.url, {proxy:'https://site.com'})).pipe(resp)
>
> -Mikeal
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] NodeJS ReadStream not reading bufferSize bytes at a time

2012-08-03 Thread Dominic Tarr
Gill, the kPool is a large buffer that ReadStream cuts buffers out of,
I think, to minimize the allocation of memory...

I was reading through this the other day, and noticed that the default
buffer size is larger than the default kPoolSize. that seems wrong.

you'd need to recompile node, of course, but making kPoolSize larger
should work.

On Fri, Aug 3, 2012 at 8:50 AM, Gill  wrote:
> I think this is related: https://github.com/joyent/node/issues/2098
>
>  - Gill
>
>
> On Thursday, 2 August 2012 23:32:39 UTC-7, Gill wrote:
>>
>> Ben, thanks for the reply. I have a doubt that its just a hint, because
>> how come it is exactly 40960 bytes every time. The underlying filesystem is
>> a custom coded one, which WILL return the exact number of bytes that were
>> asked for. Line 38 for /lib/fs.js says:
>>
>> var kPoolSize = 40 * 1024;
>>
>> Do you think changing it to 128 * 1024 will change anything?
>>
>>  - Gill
>>
>> On Thursday, 2 August 2012 16:29:43 UTC-7, Ben Noordhuis wrote:
>>>
>>> On Thu, Aug 2, 2012 at 9:21 PM, Gill  wrote:
>>> > I have a code where the NodeJS server reads a file and streams it to
>>> > response, it looks like:
>>> >
>>> > var fStream = fs.createReadStream(filePath, {'bufferSize': 128 *
>>> > 1024});
>>> > fStream.pipe(response);
>>> >
>>> > The issue is, Node reads the file exactly 40960 bytes a time. However,
>>> > my
>>> > app would be much more efficient (due to reasons not applicable to this
>>> > question), if it reads 131072 (128 * 1024) bytes at a time.
>>> >
>>> > Is there a way to force Node to read 128 * 1024 bytes at a time from
>>> > the
>>> > stream?
>>> >
>>> > Thanks in advance!
>>>
>>> No. bufferSize is a hint, not an imperative. It's up to the operating
>>> system to honor it.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Node.js under OSX

2012-08-03 Thread Jose G. Quenum
Hi Bodo,
choosing Homebrew over Mac Ports was the right thing to do as far as I can 
tell. I made the change about two years ago and have never regretted it. 
Anyway, node.js on os x works just fine for me
José
On 3 Aug 2012, at 10:56, kyogron  wrote:

> Hi,
> 
> I have now switched from GNU/Linux to Mac OSX.
> 
> I am quite uncertain about managing dev-packages but I also may have to say 
> that I am archlinux spoilt.
> 
> However I finally managed installing node, mongodb and redis through Homebrew.
> As editor I use sublime text2. 
> 
> I would now like to know if choosing Homebrew over MacPorts was a good 
> decision and if there are other things to mention about using node under OSX
> 
> In the meantime I will try to use automator to start mongodb and redis on 
> boot up.
> 
> Best Regards,
> Bodo
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] actionHero Version 3: Websockets and more!

2012-08-03 Thread hd nguyen
Thanks for your great work, I just read its description but seem it's quite
worthy to take a look :)

On Fri, Aug 3, 2012 at 11:13 AM, Evan  wrote:

> Hello Node.js Community -
>
> I want to announce the release of actionHero version 3.  This release adds
> web socket support as a first-class protocol (via socket.io) as well as
> improvements to the task system.  actionHero is an API framework which
> makes is possible to serve up http(s), webcocket, and direct TCP clients.
>  It features clustering and message passing (based on redis), 'chat room'
> logic, and a built-in delayed-job processing engine.
>
> Check it out here [[ http://actionherojs.com/ ]]. I always welcome
> feedback!
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>



-- 
Nguyen Hai Duy
Mobile : 0914 72 1900
Yahoo: nguyenhd_lucky

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] NodeJS ReadStream not reading bufferSize bytes at a time

2012-08-03 Thread Gill
In this particular application, I do not have to worry too much about 
memory usage. The focus is to read as much data from the file system as 
possible, in one read operation.

I will try increasing the kPoolSize and recompile Node. I will update this 
thread with results.

Thanks guys.

 - Gill



On Friday, 3 August 2012 02:48:49 UTC-7, Dominic wrote:
>
> Gill, the kPool is a large buffer that ReadStream cuts buffers out of, 
> I think, to minimize the allocation of memory... 
>
> I was reading through this the other day, and noticed that the default 
> buffer size is larger than the default kPoolSize. that seems wrong. 
>
> you'd need to recompile node, of course, but making kPoolSize larger 
> should work. 
>
> On Fri, Aug 3, 2012 at 8:50 AM, Gill  wrote: 
> > I think this is related: https://github.com/joyent/node/issues/2098 
> > 
> >  - Gill 
> > 
> > 
> > On Thursday, 2 August 2012 23:32:39 UTC-7, Gill wrote: 
> >> 
> >> Ben, thanks for the reply. I have a doubt that its just a hint, because 
> >> how come it is exactly 40960 bytes every time. The underlying 
> filesystem is 
> >> a custom coded one, which WILL return the exact number of bytes that 
> were 
> >> asked for. Line 38 for /lib/fs.js says: 
> >> 
> >> var kPoolSize = 40 * 1024; 
> >> 
> >> Do you think changing it to 128 * 1024 will change anything? 
> >> 
> >>  - Gill 
> >> 
> >> On Thursday, 2 August 2012 16:29:43 UTC-7, Ben Noordhuis wrote: 
> >>> 
> >>> On Thu, Aug 2, 2012 at 9:21 PM, Gill  wrote: 
> >>> > I have a code where the NodeJS server reads a file and streams it to 
> >>> > response, it looks like: 
> >>> > 
> >>> > var fStream = fs.createReadStream(filePath, {'bufferSize': 128 * 
> >>> > 1024}); 
> >>> > fStream.pipe(response); 
> >>> > 
> >>> > The issue is, Node reads the file exactly 40960 bytes a time. 
> However, 
> >>> > my 
> >>> > app would be much more efficient (due to reasons not applicable to 
> this 
> >>> > question), if it reads 131072 (128 * 1024) bytes at a time. 
> >>> > 
> >>> > Is there a way to force Node to read 128 * 1024 bytes at a time from 
> >>> > the 
> >>> > stream? 
> >>> > 
> >>> > Thanks in advance! 
> >>> 
> >>> No. bufferSize is a hint, not an imperative. It's up to the operating 
> >>> system to honor it. 
> > 
> > -- 
> > Job Board: http://jobs.nodejs.org/ 
> > Posting guidelines: 
> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines 
> > You received this message because you are subscribed to the Google 
> > Groups "nodejs" group. 
> > To post to this group, send email to nodejs@googlegroups.com 
> > To unsubscribe from this group, send email to 
> > nodejs+unsubscr...@googlegroups.com 
> > For more options, visit this group at 
> > http://groups.google.com/group/nodejs?hl=en?hl=en 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Node.js under OSX

2012-08-03 Thread kyogron
Hi,

good to hear that!

I know my time as FreeBSD Admin that managing the ports swallows a lot of 
human resources... but good to hear that using Homebrew is a good thing.

Is there actually a way of using Hombrew without Xcode?

Am Freitag, 3. August 2012 10:56:30 UTC+2 schrieb kyogron:
>
> Hi,
>
> I have now switched from GNU/Linux to Mac OSX.
>
> I am quite uncertain about managing dev-packages but I also may have to 
> say that I am archlinux spoilt.
>
> However I finally managed installing node, mongodb and redis through 
> Homebrew.
> As editor I use sublime text2. 
>
> I would now like to know if choosing Homebrew over MacPorts was a good 
> decision and if there are other things to mention about using node under OSX
>
> In the meantime I will try to use automator to start mongodb and redis on 
> boot up.
>
> Best Regards,
> Bodo
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Node.js under OSX

2012-08-03 Thread Guilherme Pim
Yep, http://kennethreitz.com/xcode-gcc-and-homebrew.html.

Guilherme

2012/8/3 kyogron 

> Hi,
>
> good to hear that!
>
> I know my time as FreeBSD Admin that managing the ports swallows a lot of
> human resources... but good to hear that using Homebrew is a good thing.
>
> Is there actually a way of using Hombrew without Xcode?
>
> Am Freitag, 3. August 2012 10:56:30 UTC+2 schrieb kyogron:
>>
>> Hi,
>>
>> I have now switched from GNU/Linux to Mac OSX.
>>
>> I am quite uncertain about managing dev-packages but I also may have to
>> say that I am archlinux spoilt.
>>
>> However I finally managed installing node, mongodb and redis through
>> Homebrew.
>> As editor I use sublime text2.
>>
>> I would now like to know if choosing Homebrew over MacPorts was a good
>> decision and if there are other things to mention about using node under OSX
>>
>> In the meantime I will try to use automator to start mongodb and redis on
>> boot up.
>>
>> Best Regards,
>> Bodo
>>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: [Help] Expree Not Caching Static Files

2012-08-03 Thread Charles McGuinness
The code you have is:

app.use(express.static(__dirname + '/public'), { maxAge: oneYear });


However, { maxAge ... } is a parameter to static(), not use(), and so the 
correct code is:

app.use(express.static(__dirname + '/public', { maxAge: oneYear } ));


That should fix it! 

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Simple Memcached server in Javascript with 100 lines of code

2012-08-03 Thread Tim Caswell
Reducing GC pauses is a tricky problem.  The best advice I can give is
allocate less objects.  Remember that functions, closures, and arrays
are also objects.  But don't do this blindly without understanding at
the expense of making your code more complicated.  Look at the V8
command-line options in node.  I remember there being several to
expose gc events (as well as optimizer events).

On Fri, Aug 3, 2012 at 1:48 AM, junyi sun  wrote:
> Hi guys,
>
> I am studying node.js. It is a wonderful utility to write network-based
> application.
>
> Now, I have written a memcached server using node.js.  You can have a look
> at https://gist.github.com/3244607
>
> I tested the program, and found it could reach 12000/s throughput. However,
> during the test, I found sometimes the speed suddenly decreased due to the
> GC pause from my mind.
>
>
> Is there a way to improve my code ?
>
>
>
> Thanks
>
> Junyi
>
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] --max-old-space-size v8 options not working with sizes>1900 in v0.8.x

2012-08-03 Thread Thomas Fritz
Hi,

I just tried to increase the heap size of v8.


node --max-old-space-size=4096 script.js


Every size above about 1900 is ignored.
I am definately on a x86_64 machine. So higher limits should work.
Has this behaviour maybe changed in the past. It is described to be
working here 
http://blog.caustik.com/2012/04/11/escape-the-1-4gb-v8-heap-limit-in-node-js/
at least.

I tried it with v0.8.4 and v0.8.5. I installed the versions with nvm.

Has anyone the same behaviour?


Kind regards

---

Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Serving static files, but not from public directory?

2012-08-03 Thread Felix E. Klee
What is a good module to serve some static (JavaScript) files (including
caching and compression)?

Desired mapping of files to URLs:

  scripts/*.js -> http://example.com/scripts/*.js (only for development)
  xyz.js   -> http://example.com/xyz.js
  app.js   -> not served (of course)
  package.json -> not served (of course)
  ...

That's it. There is no public directory in my app.

What I already looked at:

* node-static: only allows specification of a public directory which is
  mapped to the root of . As you can see above,
  this is not what I want.

* connect: will not do caching anymore ("connect.staticCache() is
  deprecated and will be removed in 3.0 use varnish or similar reverse
  proxy caches")

By the way, I plan to deploy to Nodejitsu. Does anyone know whether they
do automatic caching?

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: [Help] Expree Not Caching Static Files

2012-08-03 Thread Arunoda Susiripala
Oh yes.
Thanks for showing that.

On Fri, Aug 3, 2012 at 7:41 PM, Charles McGuinness wrote:

> The code you have is:
>
> app.use(express.static(__dirname + '/public'), { maxAge: oneYear });
>
>
> However, { maxAge ... } is a parameter to static(), not use(), and so the
> correct code is:
>
> app.use(express.static(__dirname + '/public', { maxAge: oneYear } ));
>
>
> That should fix it!
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>



-- 
Arunoda Susiripala

@arunoda 
https://github.com/arunoda
http://www.linkedin.com/in/arunoda

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Node.js under OSX

2012-08-03 Thread Bodo Kaiser
Hi,

I started with Xcode Command Line Tool support like mentioned in your link but 
got stuck with some dependency of homebrew which required the full xcode IDE.

Can you confirm this?


Am 03.08.2012 um 15:32 schrieb Guilherme Pim :

> Yep, http://kennethreitz.com/xcode-gcc-and-homebrew.html.
> 
> Guilherme
> 
> 2012/8/3 kyogron 
> Hi,
> 
> good to hear that!
> 
> I know my time as FreeBSD Admin that managing the ports swallows a lot of 
> human resources... but good to hear that using Homebrew is a good thing.
> 
> Is there actually a way of using Hombrew without Xcode?
> 
> Am Freitag, 3. August 2012 10:56:30 UTC+2 schrieb kyogron:
> Hi,
> 
> I have now switched from GNU/Linux to Mac OSX.
> 
> I am quite uncertain about managing dev-packages but I also may have to say 
> that I am archlinux spoilt.
> 
> However I finally managed installing node, mongodb and redis through Homebrew.
> As editor I use sublime text2. 
> 
> I would now like to know if choosing Homebrew over MacPorts was a good 
> decision and if there are other things to mention about using node under OSX
> 
> In the meantime I will try to use automator to start mongodb and redis on 
> boot up.
> 
> Best Regards,
> Bodo
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Serving static files, but not from public directory?

2012-08-03 Thread Tim Caswell
What kind of caching do you want?  This is a complicated issue.  And
are you also talking about conditional http requests (Etag,
timestamps, 304 responses)?  What about range request support?

A simple filter in front of any off-the-shelf static file server
should five you 95% of what you want.

var staticHandler = require('creationix').static("/", __dirname);
function (req, res, next) {
  if (!req.uri) { req.uri = urlParse(req.url); } // parse the url if
it hasn't been parsed by another middleware
  if (req.uri.pathname === "/app.js" ||
!req.uri.pathname.match(/\.js$/)) return next();
  staticHandler(req, res, next);
}

Then you'll mount / -> / but only if it ends in ".js" and is not app.js.

If you don't mind caching your files in memory, then just read the
files to ram (either at startup or on demand) and watch the files for
changes (if you want to pick up changes) to invalidate your cache.

There may be an existing module that does everything you want out of
the box, but most likely, nothing is 100% what you want.  Just build
what you want using simple modules (mime or my simple-mime, for
example to get mime type) and code you type.  Don't fall into the trap
of using a large library that only does 50% of what you need and then
spend more time tweaking/hacking it than you would spend just building
what you want from scratch.

On Fri, Aug 3, 2012 at 9:46 AM, Felix E. Klee  wrote:
> What is a good module to serve some static (JavaScript) files (including
> caching and compression)?
>
> Desired mapping of files to URLs:
>
>   scripts/*.js -> http://example.com/scripts/*.js (only for development)
>   xyz.js   -> http://example.com/xyz.js
>   app.js   -> not served (of course)
>   package.json -> not served (of course)
>   ...
>
> That's it. There is no public directory in my app.
>
> What I already looked at:
>
> * node-static: only allows specification of a public directory which is
>   mapped to the root of . As you can see above,
>   this is not what I want.
>
> * connect: will not do caching anymore ("connect.staticCache() is
>   deprecated and will be removed in 3.0 use varnish or similar reverse
>   proxy caches")
>
> By the way, I plan to deploy to Nodejitsu. Does anyone know whether they
> do automatic caching?
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Node.js under OSX

2012-08-03 Thread Guilherme Pim
Uhm.. not really, I haven't run into any Xcode dependency.. what are you
trying to install with Brew?

2012/8/3 Bodo Kaiser 

> Hi,
>
> I started with Xcode Command Line Tool support like mentioned in your link
> but got stuck with some dependency of homebrew which required the full
> xcode IDE.
>
> Can you confirm this?
>
>
> Am 03.08.2012 um 15:32 schrieb Guilherme Pim :
>
> Yep, http://kennethreitz.com/xcode-gcc-and-homebrew.html.
>
> Guilherme
>
> 2012/8/3 kyogron 
>
>> Hi,
>>
>> good to hear that!
>>
>> I know my time as FreeBSD Admin that managing the ports swallows a lot of
>> human resources... but good to hear that using Homebrew is a good thing.
>>
>> Is there actually a way of using Hombrew without Xcode?
>>
>> Am Freitag, 3. August 2012 10:56:30 UTC+2 schrieb kyogron:
>>>
>>> Hi,
>>>
>>> I have now switched from GNU/Linux to Mac OSX.
>>>
>>> I am quite uncertain about managing dev-packages but I also may have to
>>> say that I am archlinux spoilt.
>>>
>>> However I finally managed installing node, mongodb and redis through
>>> Homebrew.
>>> As editor I use sublime text2.
>>>
>>> I would now like to know if choosing Homebrew over MacPorts was a good
>>> decision and if there are other things to mention about using node under OSX
>>>
>>> In the meantime I will try to use automator to start mongodb and redis
>>> on boot up.
>>>
>>> Best Regards,
>>> Bodo
>>>
>>  --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] A method to get memory profiles that works?

2012-08-03 Thread Axel Kittenberger
Dear all,

Since my node server needs far more memory than I think it should, I
tried to get a memory profile of it.
How do I get it? Something that works? (node v0.8.5, viewing in Chrome
20.0.1132.57)

for example I followed the tutorial at
https://github.com/felixge/node-memory-leak-tutorial

It all looks nice, except for me there is no profile button

I tried

var profiler= require('v8-profiler');
...
console.log(util.inspect(profiler.takeSnapshot('1')));

and get

node: symbol lookup error:
/home/axel/meshcraft/node_modules/v8-profiler/build/Release/profiler.node:
undefined symbol: _ZNK2v813HeapGraphNode17GetRetainersCountEv

bnoordhuis profiler ( https://github.com/bnoordhuis/node-profiler )
looks to do CPU only (that works! but now what I need)

Now I do not know what else to try, help!

Kind regards,
Axel

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Node.js under OSX

2012-08-03 Thread Bodo Kaiser
I found that this was just a Homebrew + Node issue:

https://github.com/mxcl/homebrew/issues/13337

when only having Xcode with command line tool support.

But there is an easy fix switching some path in Xcode

Am 03.08.2012 um 18:47 schrieb Guilherme Pim :

> Uhm.. not really, I haven't run into any Xcode dependency.. what are you 
> trying to install with Brew?
> 
> 2012/8/3 Bodo Kaiser 
> Hi,
> 
> I started with Xcode Command Line Tool support like mentioned in your link 
> but got stuck with some dependency of homebrew which required the full xcode 
> IDE.
> 
> Can you confirm this?
> 
> 
> Am 03.08.2012 um 15:32 schrieb Guilherme Pim :
> 
>> Yep, http://kennethreitz.com/xcode-gcc-and-homebrew.html.
>> 
>> Guilherme
>> 
>> 2012/8/3 kyogron 
>> Hi,
>> 
>> good to hear that!
>> 
>> I know my time as FreeBSD Admin that managing the ports swallows a lot of 
>> human resources... but good to hear that using Homebrew is a good thing.
>> 
>> Is there actually a way of using Hombrew without Xcode?
>> 
>> Am Freitag, 3. August 2012 10:56:30 UTC+2 schrieb kyogron:
>> Hi,
>> 
>> I have now switched from GNU/Linux to Mac OSX.
>> 
>> I am quite uncertain about managing dev-packages but I also may have to say 
>> that I am archlinux spoilt.
>> 
>> However I finally managed installing node, mongodb and redis through 
>> Homebrew.
>> As editor I use sublime text2. 
>> 
>> I would now like to know if choosing Homebrew over MacPorts was a good 
>> decision and if there are other things to mention about using node under OSX
>> 
>> In the meantime I will try to use automator to start mongodb and redis on 
>> boot up.
>> 
>> Best Regards,
>> Bodo
>> 
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>> 
>> 
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] A method to get memory profiles that works?

2012-08-03 Thread Diogo Resende
http://nodetime.com/

-- 
Diogo Resende


On Friday, August 3, 2012 at 17:48 , Axel Kittenberger wrote:

> Dear all,
> 
> Since my node server needs far more memory than I think it should, I
> tried to get a memory profile of it.
> How do I get it? Something that works? (node v0.8.5, viewing in Chrome
> 20.0.1132.57)
> 
> for example I followed the tutorial at
> https://github.com/felixge/node-memory-leak-tutorial
> 
> It all looks nice, except for me there is no profile button
> 
> I tried
> 
> var profiler = require('v8-profiler');
> ...
> console.log(util.inspect(profiler.takeSnapshot('1')));
> 
> and get
> 
> node: symbol lookup error:
> /home/axel/meshcraft/node_modules/v8-profiler/build/Release/profiler.node:
> undefined symbol: _ZNK2v813HeapGraphNode17GetRetainersCountEv
> 
> bnoordhuis profiler ( https://github.com/bnoordhuis/node-profiler )
> looks to do CPU only (that works! but now what I need)
> 
> Now I do not know what else to try, help!
> 
> Kind regards,
> Axel
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com 
> (mailto:nodejs@googlegroups.com)
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com 
> (mailto:nodejs+unsubscr...@googlegroups.com)
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] how to do performance test of my POST service

2012-08-03 Thread josh
I am trying to improve our existing file upload API (using sinatra) and see 
if Node can be a better alternative.
i am using formidable to upload the file, than I stream(read) the file from 
disk into put request that saves it on our cloud servers, and finally, I 
save some meta data into a mysql. 
I make sure nothing is blocking and never load the file into memory, by 
using streaming.

please review my code and let me know what can I improve.
also, i tested it with jmeter and here are the results: 
http://i.imgur.com/PSWjH.png?1http://i.imgur.com/PSWjH.png?1
I set it up with 20 concurrent connections for 1 minute.

the problem with my test is it relies on the network connection and i don't 
really know how much time was spent on the server itself, 
how much memory, cpu and bandwidth was used? what is the speed of disk 
writes my server can handle?

one idea i can think of is taking samples from top command on the server to 
figure out the memory and cpu.
any tips/tools ideas or other things i should do?

here  is most of the code (with syntax 
highlight) and I also pasted it here: 

// server.js

process.env.TMP = '/tmp/upload';

// core modules
var http = require('http');
var util = require('util');

// non-core packages
var formidable = require('formidable'); // easy handling of file uploads
var mysql = require('mysql');

// my modules
var saveMeta = require('./saveMeta.js'); // save name in mysql
var saveFile = require('./saveFile.js'); // save file on my private cloud

var connection = mysql.createConnection({
  host : 'localhost',
  database : 'test',
  user : '',
  password : '',
});

connection.connect();

http.createServer(function(req, res) {
  // curl -F "myupload=@/pic.JPG" 0.0.0.0:3001/api -v
  if (req.url == '/api' && req.method.toLowerCase() == 'post') {
// parse a file upload
var form = new formidable.IncomingForm();

form.parse(req, function(err, fields, files) {
  res.writeHead(200);
  res.end();
});

form.on('file', function(name, file) {
  //save file in private cloud and save meta info in mysql
  saveFile(connection, file.name, file.path, saveMeta);
});

return;
  }

}).listen(3001);


// -
// saveFile.js

module.exports = saveFile;

var fs = require('fs');
var request = require('request');


// get file size and send to my cloud
//
// arguments:
// connection - mysql connection
// name - original file name
// path - path on temp directory
// saveMeta -  callback for saving into mysql
function saveFile(connection, name, path, saveMeta) {
  //adding a random number to file name. my cloud require unique names
  var rand = Math.floor(Math.random()*1).toString(); 
  var url = 'http://my-private-cloud.com:5000/test-' + rand;

  function getFileSize(cb) {
fs.stat(path, function(err, stats) {
  if(err) {
console.log('error while reading the file:' + path, err);
  } else {
if(cb) {
  cb(stats.size);
}
  }
});
  };

  // stream(read) the file from hardrive into put request that saves it on 
our cloud
  //
  // curl -sSf -T file1 http://my-private-cloud.com:5000/test
  // 200 - file was saved
  // anything else - file was not saved
  function sendFileToCloud(fileSize) {
var file = fs.createReadStream(path)
  .pipe(request.put({url: url, headers:{'Content-Length': fileSize}}, 
function(err, res, body){
if(err) {
  console.log('error in PUT request to my cloud:', err);
} else {
  // console.log('status from cloud:', res.statusCode);
  // console.log('file url:', url);
  if(res.statusCode === 200) {
saveMeta(connection, name, path, url) 
  }
}
  }));

file.on('data', function(chunk) {
})

file.on('end', function() {
});

file.on('error', function(e) {
  console.log('error:', e);
});
  };

  getFileSize(sendFileToCloud);
};

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] A method to get memory profiles that works?

2012-08-03 Thread Axel Kittenberger
> http://nodetime.com/

I forgot to mention that, nope, basically work, but the output is far
off and honestly I don't really want to upload my memory dumps to some
offsite service

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Serving static files, but not from public directory?

2012-08-03 Thread Felix E. Klee
On Fri, Aug 3, 2012 at 5:16 PM, Tim Caswell  wrote:
> What kind of caching do you want?

Actually it's just one file that needs *caching* and *compression*:

http://example.com/xyz.js

The other files are just exposed for development (process.env.NODE_ENV
!== 'production'):

http://example.com/scripts/*.js

And, then I want to provide Socket.IO. Fortunately, the Socket.IO module
is taking care of serving itself.

What is all this? It's an API that users interface with via an object
provided by `xyz.js`. In a way it's similar to the YouTube API. There
you first load some JavaScript, and then you interact with the `YT`
object, to: load a new video, play it, stop it, etc.

The contents of the directory `script` are a bunch of AMD modules. They
are the building blocks of `xyz.js`.

> And are you also talking about conditional http requests (Etag,
> timestamps, 304 responses)? What about range request support?

Nothing complicated - see above. No redirects, no error page, etc.

> A simple filter in front of any off-the-shelf static file server
> should five you 95% of what you want.

I don't want to use a separate file server.

> var staticHandler = require('creationix').static("/", __dirname);

Looks interesting! Reading the source of `static()`...

> Then you'll mount / -> / but only if it ends in ".js" and is not
> app.js.

There are more files that I don't want to serve in `/`. In fact, for
security reasons, I don't want to mount `/` at all...

> If you don't mind caching your files in memory, then just read the
> files to ram (either at startup or on demand) and watch the files for
> changes (if you want to pick up changes) to invalidate your cache.

I see. That's a start for `xyz.js`. I could just use `fs.watchFile`.
Then I also need to think about compression. But perhaps the Nodejitsu
folks take care of that.

> Don't fall into the trap of using a large library that only does 50%
> of what you [...]

OTOH I don't have any special requirements, and so writing my own static
file serving code - while surely instructional - seems like reinventing
the wheel.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: actionHero Version 3: Websockets and more!

2012-08-03 Thread Jeff Barczewski
Evan, 

Could you explain more simply what the goals of your project is?

I read the description:

actionHero is a node.js API framework for both tcp sockets, web sockets, 
and http clients. The goals of actionHero are to create an easy-to-use 
toolkit for making reusable, scalable, and polygot APIs. actionHero 
provides cluster support, shared cache, integrated delayed processing, and 
more.


So for someone unfamiliar with your project, does this project try to make 
it easier to deal with tcp sockets, web sockets, and http clients in a 
consistent way? Is that the main emphasis for the project (create actions 
that can be executed from any of these delivery mechanisms)? 

I do understand you are bundling in delayed processing, shared cache (from 
Redis), so since those are bundled in, one doesn't have to figure out how 
to integrate manually especially for dealing with a cluster.

Traditionally I have seen 'polyglot' referring to different languages for 
example a project using JS, C, java, for different parts of the 
application, however for your project, it appears to only support JS 
currently. Does the polyglot API's reference simply refer to the ability to 
listen via tcp sockets, web sockets, and HTTP?


Thanks in advance for any clarification. I just wanted to make sure I 
understood what the project is focussed on.

All the best,

Jeff

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: --max-old-space-size v8 options not working with sizes>1900 in v0.8.x

2012-08-03 Thread Thomas Fritz
How do i increase the maximum memory a single node process can use?
I tried under Linux and Mac OSX and i could not increase it with the 
max-old-space-size.
Every value above 1900 gets ignored. Is this intended behaviour? Or am i doing 
something
wrong?

Kind regards


Am 03.08.2012 um 16:36 schrieb Thomas Fritz :

> Hi,
> 
> I just tried to increase the heap size of v8.
> 
> 
> node --max-old-space-size=4096 script.js
> 
> 
> Every size above about 1900 is ignored.
> I am definately on a x86_64 machine. So higher limits should work.
> Has this behaviour maybe changed in the past. It is described to be
> working here 
> http://blog.caustik.com/2012/04/11/escape-the-1-4gb-v8-heap-limit-in-node-js/
> at least.
> 
> I tried it with v0.8.4 and v0.8.5. I installed the versions with nvm.
> 
> Has anyone the same behaviour?
> 
> 
> Kind regards
> 
> ---
> 
> Thomas FRITZ
> web http://fritzthomas.com
> twitter http://twitter.com/thomasf

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Node.js under OSX

2012-08-03 Thread Guilherme Pim
Great then!

2012/8/3 Bodo Kaiser 

> I found that this was just a Homebrew + Node issue:
>
> https://github.com/mxcl/homebrew/issues/13337
>
> when only having Xcode with command line tool support.
>
> But there is an easy fix switching some path in Xcode
>
> Am 03.08.2012 um 18:47 schrieb Guilherme Pim :
>
> Uhm.. not really, I haven't run into any Xcode dependency.. what are you
> trying to install with Brew?
>
> 2012/8/3 Bodo Kaiser 
>
>> Hi,
>>
>> I started with Xcode Command Line Tool support like mentioned in your
>> link but got stuck with some dependency of homebrew which required the full
>> xcode IDE.
>>
>> Can you confirm this?
>>
>>
>> Am 03.08.2012 um 15:32 schrieb Guilherme Pim :
>>
>> Yep, http://kennethreitz.com/xcode-gcc-and-homebrew.html.
>>
>> Guilherme
>>
>> 2012/8/3 kyogron 
>>
>>> Hi,
>>>
>>> good to hear that!
>>>
>>> I know my time as FreeBSD Admin that managing the ports swallows a lot
>>> of human resources... but good to hear that using Homebrew is a good thing.
>>>
>>> Is there actually a way of using Hombrew without Xcode?
>>>
>>> Am Freitag, 3. August 2012 10:56:30 UTC+2 schrieb kyogron:

 Hi,

 I have now switched from GNU/Linux to Mac OSX.

 I am quite uncertain about managing dev-packages but I also may have to
 say that I am archlinux spoilt.

 However I finally managed installing node, mongodb and redis through
 Homebrew.
 As editor I use sublime text2.

 I would now like to know if choosing Homebrew over MacPorts was a good
 decision and if there are other things to mention about using node under 
 OSX

 In the meantime I will try to use automator to start mongodb and redis
 on boot up.

 Best Regards,
 Bodo

>>>
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to nodejs@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> nodejs+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Version 0.6.21 (maintenance)

2012-08-03 Thread Isaac Schlueter
2012.08.03 Version 0.6.21 (maintenance)

* sunos: work around OS bug to prevent fs.watch() from spinning (Bryan Cantrill)

* net: make pause/resume work with connecting sockets (Bert Belder)


Source Code: http://nodejs.org/dist/v0.6.21/node-v0.6.21.tar.gz

Windows Installer: http://nodejs.org/dist/v0.6.21/node-v0.6.21.msi

Windows x64 Files: http://nodejs.org/dist/v0.6.21/x64/

Macintosh Installer (Universal): http://nodejs.org/dist/v0.6.21/node-v0.6.21.pkg

Other release files: http://nodejs.org/dist/v0.6.21/

Website: http://nodejs.org/docs/v0.6.21/

Documentation: http://nodejs.org/docs/v0.6.21/api/

Shasums:

```
04f58b0da23c3db291d84ac55a924332ad83c427  node-v0.6.21.pkg
31f564bf34c64b07cae3b9a88a87b4a08bab4dc5  node-v0.6.21.tar.gz
1e3184fe2cfe7140a88b5dcc9c2ec7d32f1f5af5  node.exe
b8887a056152622c08ee10f5867bd27910260477  node.exp
c6468ffe2e145e7db1bb3e2d66adb9f5d50271ad  node.lib
2a896bcb7c83f2fa710650116580daf4ac5e6c4c  node.msi
207441e8c3dc184c478367b775dc7ece1ee36501  node.pdb
715ad9946db5f97c54a53bdea6bbe9ba69f2f299  x64/node.exe
2fa2c2d82fedeec1ed8be5d908b790f473d4a7c2  x64/node.exp
b403cb71d4cf21e97a78d446403cedc9795bcf69  x64/node.lib
ef47520dbc6a1a68ec37d290c421031cfd670048  x64/node.msi
fb15e3991c420f3ae67ade92b11b07bb9112124a  x64/node.pdb
```

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Which approach will be better for performance and stability.

2012-08-03 Thread Jai
Hello,

I am struggling with few approaches to run Node.js, before I go for 
benchmark which requires lot of work I wanted more experienced users to 
comment on following approaches.

Aim is to run a chat like project that needs to scale, requires fail-over 
and should have low latency. We will have multiple servers in different 
locations.
Apart from above considerations we should also consider difficulty of 
coding in these approaches.

Approach one
1) Multiple servers say X,Y,Z
2) Every server has multiple node.js (NJ) process say A,B,C
3) Stats server keeps no.of connections log of all NJ process on all 
servers. Hence it knows which NJ has high load.
4) Each NJ process keeps track of connected users (room information), this 
info is not shared.
5) All room users connect to single process of server X and single process 
of Y for e.g. they connect to A.of.X and C.of.Y
Users can send packet to any of these two process and that packet will be 
broadcasted to everyone in room.
Users connect with two process on different server for failover, users can 
send message to each process in round robin fashion.
6) Latency checks between all users and servers is made in background. All 
users in room are prompted to switch to preferred two servers.
Stats server is also checked to see if preferred servers already has high 
load.
It is important that all users in room connect to same pair of NJ process.
==
I am not sure if it would be possible to change websocket connection to a 
different servers as mentioned in (6)

Approach two
1) Multiple servers say X,Y,Z
2) Every server has multiple node.js (NJ) process say A,B,C
3) Some kind of load balancer (HAProxy) is used to share load between all 
A,B,C processes between server.
4) Stats server keeps no.of connections log of all HAProxy. Hence it knows 
which HAProxy has high load.
4) Rooms info is stored in database (REDIS) which is shared between all NJ 
of server.
5) All room users connect to a pair of servers.
Users can send packet to any of these servers and that packet will be 
broadcasted to everyone in room.
Users connect with two servers for failover, users can send message to each 
server in round robin fashion.
6) Latency checks between all users and servers is made in background. All 
users in room are prompted to switch to preferred two servers.
Stats server is also checked to see if preferred servers already has high 
load.
It is important that all users in room connect to same pair of servers.
==
Maybe node.js cluster module can be used in place of HAProxy.

Approach three
1) Multiple servers say X,Y,Z
2) Every server has multiple node.js (NJ) process say A,B,C
3) Some kind of load balancer (HAProxy) is used to share load between all 
A,B,C processes between ALL servers.
4) Stats server keeps no.of connections log of all HAProxy. Hence it knows 
which HAProxy has high load.
4) Rooms info is stored in database (REDIS) which is shared between all NJ 
of every server.
5) Users can connect to any server.
6) Using geographical LB (or DDNS approach) users are directed to server 
closer to them.
Users in one room need not have to connect with same server.
==
All servers connect to central (redundant) REDIS server, this would 
increase response time as NJ has to wait for network connect time to get 
room list before broadcasting packets.

Approach four
Compared to Approach three, here instead of keeping a central REDIS we keep 
synced copies of REDIS on every server. This would eliminate network 
connect time but would increase memory footprint.

What do you say?

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] --max-old-space-size v8 options not working with sizes>1900 in v0.8.x

2012-08-03 Thread Ben Noordhuis
On Fri, Aug 3, 2012 at 4:36 PM, Thomas Fritz  wrote:
> Hi,
>
> I just tried to increase the heap size of v8.
>
> 
> node --max-old-space-size=4096 script.js
> 
>
> Every size above about 1900 is ignored.
> I am definately on a x86_64 machine. So higher limits should work.
> Has this behaviour maybe changed in the past. It is described to be
> working here 
> http://blog.caustik.com/2012/04/11/escape-the-1-4gb-v8-heap-limit-in-node-js/
> at least.
>
> I tried it with v0.8.4 and v0.8.5. I installed the versions with nvm.
>
> Has anyone the same behaviour?

No. What makes you think that it's ignored? It seems to work for me.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Node.js under OSX

2012-08-03 Thread Ryan Schmidt
Speaking as a manager of the MacPorts project I am clearly biased, but as far 
as I can tell nodejs works fine when installed by MacPorts, so use whichever 
you prefer.

On Aug 3, 2012, at 03:56, kyogron  wrote:

> I would now like to know if choosing Homebrew over MacPorts was a good 
> decision and if there are other things to mention about using node under OSX

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Last day to buy NodeConf SummerCamp tickets

2012-08-03 Thread Mikeal Rogers
I talked with the camp and was able to extend the ticket sale until Thursday 
August 6th :)

The full agenda for the camp is now up on the website and I've pasted it below 
as well.

http://www.nodeconf.com/

Agenda

September 4th

Buses will leave Joyent's office in downtown San Francisco. You can arrive as 
early as 10am. The first bus leaves at 11am and the second at 3pm.

If you are driving yourself to the camp you can show up as early as 12:30pm.

In the afternoon, shortly after the first bus arrives, games of kickball and 
foursquare will begin. A lake swimming trip will head out at 3pm.

Drinks (yes, that includes beers) will be available throughout the day and in 
to the night.

Dinner will be served at 6pm.

After dinner there will be an opening talk around the campfire. After the talk 
will be the first nights party, sponsored by Yammer. The party will include a 
campfire, smores, and music in the boogie barn.

September 5th

Mimosa breakfast, sponsored by Nodejitsu, will begin at 8am. At 9:30am the SO 
track will leave for a nature hike and unconference sessions for attendees will 
being in the Buckeye Meeting room.

Drinks and snacks will be available all day in the unconference sessions.

Lunch at noon. After lunch we will return to unconference sessions until dinner 
with a short mid-day break. At 2pm the SO Track heads to the lake to go 
swimming.

Dinner at 6pm. After dinner will be campfire stories and another party, 
sponsored by ensighten, with a campfire, smores, and music in the boogie barn.

September 6th

Mimosa breakfast, sponsored by Joyent, will being at 8am. After breakfast until 
lunch is open hack time. Partner up with whomever you like around the camp and 
hack on some stuff.

Lunch at noon. After lunch you'll need to quickly get your things together to 
catch the shuttle leaving at 1pm. If you think you'll take a lot of time 
getting ready please do it before lunch. The shuttle will take everyone back to 
the Joyent office in downtown San Francisco. The total trip time varies but you 
can count on it returning before 4pm.

-Mikeal

On Aug 2, 2012, at August 2, 20129:06 PM, Charlie Key 
 wrote:

> Just got our 3 tickets. Thanks for the heads up. 
> 
> On Thursday, August 2, 2012 4:53:10 PM UTC-4, Mikeal Rogers wrote:
> We need to get a final count to the camp so this will be probably be the last 
> day that you can buy SummerCamp tickets. 
> 
> Come join me, dshaw, Paolo, isaacs, tmpvar, Max Ogden, Charlie Robbins and a 
> ton of other people in the woods geeking out about node.js :) 
> 
> https://tito.io/nodeconf/nodeconf-summercamp 
> 
> Tickets include all your meals and lots of beers the whole time :) 
> 
> -Mikeal
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] --max-old-space-size v8 options not working with sizes>1900 in v0.8.x

2012-08-03 Thread Marcel Laverdet
> I am definately on a x86_64 machine. So higher limits should work.

Are you running 64 bit node? What does `process.arch` return for you?

On Fri, Aug 3, 2012 at 9:36 AM, Thomas Fritz  wrote:

> Hi,
>
> I just tried to increase the heap size of v8.
>
> 
> node --max-old-space-size=4096 script.js
> 
>
> Every size above about 1900 is ignored.
> I am definately on a x86_64 machine. So higher limits should work.
> Has this behaviour maybe changed in the past. It is described to be
> working here
> http://blog.caustik.com/2012/04/11/escape-the-1-4gb-v8-heap-limit-in-node-js/
> at least.
>
> I tried it with v0.8.4 and v0.8.5. I installed the versions with nvm.
>
> Has anyone the same behaviour?
>
>
> Kind regards
>
> ---
>
> Thomas FRITZ
> web http://fritzthomas.com
> twitter http://twitter.com/thomasf
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] how to do performance test of my POST service

2012-08-03 Thread Martin Cooper
On Fri, Aug 3, 2012 at 9:57 AM, josh  wrote:
> I am trying to improve our existing file upload API (using sinatra) and see
> if Node can be a better alternative.
> i am using formidable to upload the file, than I stream(read) the file from
> disk into put request that saves it on our cloud servers, and finally, I
> save some meta data into a mysql.
> I make sure nothing is blocking and never load the file into memory, by
> using streaming.

It seems to me that you'd be better off by streaming the file content
directly from the incoming request to your cloud servers, instead of
writing it to disk first and then immediately reading it back just so
that you can stream it out again. I'm not sufficiently familiar with
formidable to know how this capability is exposed in the API, but I
see the low-level events in the parser, so I'm assuming there's a way.

--
Martin Cooper


> please review my code and let me know what can I improve.
> also, i tested it with jmeter and here are the results:
> http://i.imgur.com/PSWjH.png?1http://i.imgur.com/PSWjH.png?1
> I set it up with 20 concurrent connections for 1 minute.
>
> the problem with my test is it relies on the network connection and i don't
> really know how much time was spent on the server itself,
> how much memory, cpu and bandwidth was used? what is the speed of disk
> writes my server can handle?
>
> one idea i can think of is taking samples from top command on the server to
> figure out the memory and cpu.
> any tips/tools ideas or other things i should do?
>
> here is most of the code (with syntax highlight) and I also pasted it here:
>
> // server.js
>
> process.env.TMP = '/tmp/upload';
>
> // core modules
> var http = require('http');
> var util = require('util');
>
> // non-core packages
> var formidable = require('formidable'); // easy handling of file uploads
> var mysql = require('mysql');
>
> // my modules
> var saveMeta = require('./saveMeta.js'); // save name in mysql
> var saveFile = require('./saveFile.js'); // save file on my private cloud
>
> var connection = mysql.createConnection({
>   host : 'localhost',
>   database : 'test',
>   user : '',
>   password : '',
> });
>
> connection.connect();
>
> http.createServer(function(req, res) {
>   // curl -F "myupload=@/pic.JPG" 0.0.0.0:3001/api -v
>   if (req.url == '/api' && req.method.toLowerCase() == 'post') {
> // parse a file upload
> var form = new formidable.IncomingForm();
>
> form.parse(req, function(err, fields, files) {
>   res.writeHead(200);
>   res.end();
> });
>
> form.on('file', function(name, file) {
>   //save file in private cloud and save meta info in mysql
>   saveFile(connection, file.name, file.path, saveMeta);
> });
>
> return;
>   }
>
> }).listen(3001);
>
>
> // -
> // saveFile.js
>
> module.exports = saveFile;
>
> var fs = require('fs');
> var request = require('request');
>
>
> // get file size and send to my cloud
> //
> // arguments:
> // connection - mysql connection
> // name - original file name
> // path - path on temp directory
> // saveMeta -  callback for saving into mysql
> function saveFile(connection, name, path, saveMeta) {
>   //adding a random number to file name. my cloud require unique names
>   var rand = Math.floor(Math.random()*1).toString();
>   var url = 'http://my-private-cloud.com:5000/test-' + rand;
>
>   function getFileSize(cb) {
> fs.stat(path, function(err, stats) {
>   if(err) {
> console.log('error while reading the file:' + path, err);
>   } else {
> if(cb) {
>   cb(stats.size);
> }
>   }
> });
>   };
>
>   // stream(read) the file from hardrive into put request that saves it on
> our cloud
>   //
>   // curl -sSf -T file1 http://my-private-cloud.com:5000/test
>   // 200 - file was saved
>   // anything else - file was not saved
>   function sendFileToCloud(fileSize) {
> var file = fs.createReadStream(path)
>   .pipe(request.put({url: url, headers:{'Content-Length': fileSize}},
> function(err, res, body){
> if(err) {
>   console.log('error in PUT request to my cloud:', err);
> } else {
>   // console.log('status from cloud:', res.statusCode);
>   // console.log('file url:', url);
>   if(res.statusCode === 200) {
> saveMeta(connection, name, path, url)
>   }
> }
>   }));
>
> file.on('data', function(chunk) {
> })
>
> file.on('end', function() {
> });
>
> file.on('error', function(e) {
>   console.log('error:', e);
> });
>   };
>
>   getFileSize(sendFileToCloud);
> };
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, 

Re: [nodejs] how to do performance test of my POST service

2012-08-03 Thread josh
awesome advice. i wanted to do that but didn't figure it out yet!

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] NodeJS ReadStream not reading bufferSize bytes at a time

2012-08-03 Thread Gill
I changed kPoolSize to 128 * 1024, and compiled node again.

Now, Node tries to read larger chunks in each read. Although it never 
reaches 131072 bytes, but its usually in the range of 128000 to 13. It 
reads each 128*1024 chunk in two reads, first one about 128000 bytes, and 
the second one the remaining number of bytes. Although not totally 
efficient, two reads is better than the 4 reads we were getting earlier. 
Also, this is very consisted with Java's stream.read function, which also 
behaves in the same way.

 - Gill

On Friday, 3 August 2012 03:36:48 UTC-7, Gill wrote:
>
> In this particular application, I do not have to worry too much about 
> memory usage. The focus is to read as much data from the file system as 
> possible, in one read operation.
>
> I will try increasing the kPoolSize and recompile Node. I will update this 
> thread with results.
>
> Thanks guys.
>
>  - Gill
>
>
>
> On Friday, 3 August 2012 02:48:49 UTC-7, Dominic wrote:
>>
>> Gill, the kPool is a large buffer that ReadStream cuts buffers out of, 
>> I think, to minimize the allocation of memory... 
>>
>> I was reading through this the other day, and noticed that the default 
>> buffer size is larger than the default kPoolSize. that seems wrong. 
>>
>> you'd need to recompile node, of course, but making kPoolSize larger 
>> should work. 
>>
>> On Fri, Aug 3, 2012 at 8:50 AM, Gill  wrote: 
>> > I think this is related: https://github.com/joyent/node/issues/2098 
>> > 
>> >  - Gill 
>> > 
>> > 
>> > On Thursday, 2 August 2012 23:32:39 UTC-7, Gill wrote: 
>> >> 
>> >> Ben, thanks for the reply. I have a doubt that its just a hint, 
>> because 
>> >> how come it is exactly 40960 bytes every time. The underlying 
>> filesystem is 
>> >> a custom coded one, which WILL return the exact number of bytes that 
>> were 
>> >> asked for. Line 38 for /lib/fs.js says: 
>> >> 
>> >> var kPoolSize = 40 * 1024; 
>> >> 
>> >> Do you think changing it to 128 * 1024 will change anything? 
>> >> 
>> >>  - Gill 
>> >> 
>> >> On Thursday, 2 August 2012 16:29:43 UTC-7, Ben Noordhuis wrote: 
>> >>> 
>> >>> On Thu, Aug 2, 2012 at 9:21 PM, Gill  wrote: 
>> >>> > I have a code where the NodeJS server reads a file and streams it 
>> to 
>> >>> > response, it looks like: 
>> >>> > 
>> >>> > var fStream = fs.createReadStream(filePath, {'bufferSize': 128 * 
>> >>> > 1024}); 
>> >>> > fStream.pipe(response); 
>> >>> > 
>> >>> > The issue is, Node reads the file exactly 40960 bytes a time. 
>> However, 
>> >>> > my 
>> >>> > app would be much more efficient (due to reasons not applicable to 
>> this 
>> >>> > question), if it reads 131072 (128 * 1024) bytes at a time. 
>> >>> > 
>> >>> > Is there a way to force Node to read 128 * 1024 bytes at a time 
>> from 
>> >>> > the 
>> >>> > stream? 
>> >>> > 
>> >>> > Thanks in advance! 
>> >>> 
>> >>> No. bufferSize is a hint, not an imperative. It's up to the operating 
>> >>> system to honor it. 
>> > 
>> > -- 
>> > Job Board: http://jobs.nodejs.org/ 
>> > Posting guidelines: 
>> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines 
>> > You received this message because you are subscribed to the Google 
>> > Groups "nodejs" group. 
>> > To post to this group, send email to nodejs@googlegroups.com 
>> > To unsubscribe from this group, send email to 
>> > nodejs+unsubscr...@googlegroups.com 
>> > For more options, visit this group at 
>> > http://groups.google.com/group/nodejs?hl=en?hl=en 
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Simple Memcached server in Javascript with 100 lines of code

2012-08-03 Thread Jimb Esser
Best thing to try, add --nouse_idle_notification to the node command line, 
this disables the full garbage collects when node tells V8 it thinks its 
idle, but V8's garbage collection it does on every allocation should still 
take care of collecting garbage.  Give that a try, watch the RSS in top or 
your favorite process monitor to make sure it's still garbage collecting 
(doesn't just leak), and hopefully the stalls will also go away.  We found 
this totally eliminated the giant garbage collect stalls and did not 
noticeably impact process memory usage in our application.

On Thursday, August 2, 2012 11:48:15 PM UTC-7, sunjoy wrote:
>
> Hi guys,
>
> I am studying node.js. It is a wonderful utility to write network-based 
> application.
>
> Now, I have written a memcached server using node.js.  You can have a look 
> at https://gist.github.com/3244607
>
> I tested the program, and found it could reach 12000/s throughput. 
> However, during the test, I found sometimes the speed suddenly decreased 
> due to the GC pause from my mind.
>
>
> Is there a way to improve my code ?
>
>
>
> Thanks
>
> Junyi
>
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] A method to get memory profiles that works?

2012-08-03 Thread Jimb Esser
v8-profiler and node-profiler haven't been updated for newer versions of 
V8, I think. Have you tried node-webkit-agent?
https://github.com/c4milo/node-webkit-agent
Seems to work well for CPU and JS heap profiling for us when the others 
stopped working.

On Friday, August 3, 2012 10:06:42 AM UTC-7, Axel Kittenberger wrote:
>
> > http://nodetime.com/ 
>
> I forgot to mention that, nope, basically work, but the output is far 
> off and honestly I don't really want to upload my memory dumps to some 
> offsite service 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Simple Memcached server in Javascript with 100 lines of code

2012-08-03 Thread Marcel Laverdet
Yes adding --nouse-idle-notification to your node flags is definitely the
first thing you should try. You may also try avoiding objects with large
numbers of keys (like a million seems to be my ceiling).

On Fri, Aug 3, 2012 at 8:35 PM, Jimb Esser  wrote:

> Best thing to try, add --nouse_idle_notification to the node command line,
> this disables the full garbage collects when node tells V8 it thinks its
> idle, but V8's garbage collection it does on every allocation should still
> take care of collecting garbage.  Give that a try, watch the RSS in top or
> your favorite process monitor to make sure it's still garbage collecting
> (doesn't just leak), and hopefully the stalls will also go away.  We found
> this totally eliminated the giant garbage collect stalls and did not
> noticeably impact process memory usage in our application.
>
>
> On Thursday, August 2, 2012 11:48:15 PM UTC-7, sunjoy wrote:
>>
>> Hi guys,
>>
>> I am studying node.js. It is a wonderful utility to write network-based
>> application.
>>
>> Now, I have written a memcached server using node.js.  You can have a
>> look at https://gist.github.com/**3244607
>>
>> I tested the program, and found it could reach 12000/s throughput.
>> However, during the test, I found sometimes the speed suddenly decreased
>> due to the GC pause from my mind.
>>
>>
>> Is there a way to improve my code ?
>>
>>
>>
>> Thanks
>>
>> Junyi
>>
>>
>>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Node.js under OSX

2012-08-03 Thread Bodo Kaiser
@ryan

I only can speak about my experience with FreeBSD Ports.

In my opinion the work you have to put in for (administrating) compiling 
software and the benefits you are getting out of it are hard unbalanced.

In today's time software is a lot module based. I know from my gentoo time that 
compiling an own kernel didn't speed up anything... at least if we use an 
initramfs image to load modules.

However it is always good to have alternatives ;)

Am 04.08.2012 um 00:47 schrieb Ryan Schmidt :

> Speaking as a manager of the MacPorts project I am clearly biased, but as far 
> as I can tell nodejs works fine when installed by MacPorts, so use whichever 
> you prefer.
> 
> On Aug 3, 2012, at 03:56, kyogron  wrote:
> 
>> I would now like to know if choosing Homebrew over MacPorts was a good 
>> decision and if there are other things to mention about using node under OSX
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Node.js under OSX

2012-08-03 Thread Lothar Pfeiler
Hi Bodo,

I also like to mention that there is an app called CodeRunner, which 
supports node.js. It's an editor with a play-button. What I like about it 
is a really quick, mac-like way to try out some code. Whenever I have an 
idea of an algorithm in my mind, I use CodeRunner an JavaScript to try it 
out. I think it's cool for people who like small nice easy-to-use apps and 
for people, who are used to work with the Xcode editor (syntax highlighting 
and code completion).

This is just another point to show that Max OS X and node.js fit together 
perfectly.

P.S.: I first used MacPorts and then Homebrew. Somehow I wanted to try out 
both and both work.

On Friday, August 3, 2012 10:56:30 AM UTC+2, kyogron wrote:
>
> Hi,
>
> I have now switched from GNU/Linux to Mac OSX.
>
> I am quite uncertain about managing dev-packages but I also may have to 
> say that I am archlinux spoilt.
>
> However I finally managed installing node, mongodb and redis through 
> Homebrew.
> As editor I use sublime text2. 
>
> I would now like to know if choosing Homebrew over MacPorts was a good 
> decision and if there are other things to mention about using node under OSX
>
> In the meantime I will try to use automator to start mongodb and redis on 
> boot up.
>
> Best Regards,
> Bodo
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Serving static files, but not from public directory?

2012-08-03 Thread Weltschmerz
You can do this with Lactate

https://github.com/Weltschmerz/Lactate 

On Friday, August 3, 2012 9:46:37 AM UTC-5, Felix E. Klee wrote:
>
> What is a good module to serve some static (JavaScript) files (including 
> caching and compression)? 
>
> Desired mapping of files to URLs: 
>
>   scripts/*.js -> http://example.com/scripts/*.js (only for development) 
>   xyz.js   -> http://example.com/xyz.js 
>   app.js   -> not served (of course) 
>   package.json -> not served (of course) 
>   ... 
>
> That's it. There is no public directory in my app. 
>
> What I already looked at: 
>
> * node-static: only allows specification of a public directory which is 
>   mapped to the root of . As you can see above, 
>   this is not what I want. 
>
> * connect: will not do caching anymore ("connect.staticCache() is 
>   deprecated and will be removed in 3.0 use varnish or similar reverse 
>   proxy caches") 
>
> By the way, I plan to deploy to Nodejitsu. Does anyone know whether they 
> do automatic caching? 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] googleplaces.js

2012-08-03 Thread Srirangan
googleplaces.js is a node.js library for the Google Places API

I built this yesterday with help from many of you on freenode #nodejs.
It's small, lightweight and depends on nothing but built-in Node libraries.

If you have the time, please review the code. I hope I've adhered to
conventions.
Needless to say inviting forks, hacks, bug fixes and improvements.

Links:
*
http://srirangan.net/2012-08-googleplaces-js-is-a-node-js-library-for-the-google-places-api
* https://github.com/Srirangan/googleplaces.js
* https://github.com/Srirangan/googleplaces.js-examples
* https://npmjs.org/package/googleplaces

Srirangan  |  +91 9711 477 595  |  About 
GitHub 
LinkedIn
  Twitter   |  Review19
  "Collaborate
& Track Decisions"

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en