We have a NodeJS application deployed with forever. We don't know why, but this solution is generating too many defunct processes. In some cases, we need to restart manually the application because this situation collapses our server. We'are logging now the PID and timestamp to investigate the reasons, but I'm not confident that we're going to get something with this.
Has anyone this problem? What type of things do we need to check in our NodeJS application to remove this issue? I'm completely stuck and I don't know which type of things can generate this defunct processes. Our code is really simple, with JS promises, WS request, React, ...
If anyone needs some code (like package.json or whatever file) or more info, please just tell me.
Thanks!
Related
I have been developing phonegap applications that need to make updates oftenly. The problem is pushing a new ipa to iTune Store take too long. So, I uploaded the application source codes(minified javascript) to my server and download it from application and "eval" the minified js files. But i feel using eval has limitations and also not the right way. So, can someone tell me the right way to accomplish this.
thank you so much.
I'd love to have something like this as well. You're already ahead of me w/your eval() approach - but I'd have the same concerns as you there. Here's what I'm aware is out there on this topic - hope this helps?
IdeaPress(?)
I just recently caught wind of this one - not sure how feasible but it claims to do exactly what we'd like. I have to say the main site looks a bit flaky but I will definitly be checking this out to see if it's feasible or not.
HockeyApp?
HockeyApp (possibly dead-end now). I thought there used to be a pretty clear solution for PhoneGap devs to integrate the HockeyApp API/feature set with their mobile apps but a recent Google search on this is turning up much less than I would think - so maybe it's a dead end now? http://goo.gl/GQOv5o
org.apache.cordova.file
This requires more work and I haven't pushed far enough yet to see if it truly could be a means of updating the app post-app-store-deployment. But based on what I've read if you're just updating code for your WebView you shouldn't have to worry about App Store rejection or anything. Related tutorial
Testflight App Testing (Apple)
I haven't gotten to play w/this yet but sounds like it could be promising for at least the beta/testing phase of development. I, like you, need a solution for end-users, not app testers, but I'll still be looking into this soon as it might replace me having to maintain my own over-the-air app installs for the best/testing periods.
The Express node.js server application I'm currently developing will sometimes go off into the void and stops returning requests. I very much suspect somewhere in it I am doing something that is ultimately skipping a res.end that I need to be doing.
Does anyone have any tips or tricks on how to best go about looking for where I'm missing the res.end (assuming that's the problem)? Is there anyway to view the currently open requests in real time in the node event loop?
When things hang up, everything is still running in that Express will still accept incoming requests. And, these requests are logged to the console via express.logger just fine. But, the request is never returned to the client and no error is being thrown.
Thank you in advance for your thoughts.
Follow-up:
There doesn't seem to be much documentation on node's debug mode beyond the raw API docs. I did find this article which seems to provide a good overview of several options. But, there doesn't seem to be the kind of thing I was thinking of for watching the event loop, something a la vtop's process list.
More Follow-up:
Yesterday, Daniel Hood published Debugging in Node.js stating that, "The state of debugging node.js apps has always been a bit unfortunate..." So, perhaps my question is not so silly as to merit down votes as it might seem. Anyway, in his next article he promises to cover some tools for debugging asynchronous operations.
I posted the last article you mentioned. If you need to debug async stuff, I'll be going over things like long stack traces (modules such longjohn), the try-catch module, and things like zones/domains. Hopefully those links will be of some help (might be a week before I write part 2).
However, for your particular issue, have you tried setting a breakpoint at some known location and stepping through the process? This way you can just watch how the app is executed, and maybe find where some function is returning nothing when it should be returning the req/res object.
If it isn't very reproducible, maybe some simple logging would be helpful.
I've made a server in nowjs, and with about 80 users online it get slow and sometimes people get disconnect. I've heared about that I have to change the workers count. But how to do it? and is it a solution? Or maybe there are another advices.
Since you mentioned writing log data to file and is larger, make sure you're using right Node asynch file i/o so is not blocking -- can use with optional callbacks. Better yet, creating a write stream is the way to go (Node is great for it's asynch file streaming capabilities).
You may have hit a scaling issue, 80 users seems low to me.
Are you sure you are not doing any kind of logic on your server side that could be blocking ?
Any math or something that require too much time ?
If you have a scaling issue, you may need to horizontally scale you app.
To do so you would have to use something like node cluster to have multiple workers handling the work, and a Redis or a Mongo used for handling shared the data, it might be possible to do using message in node cluster.
I've not push now.js that far yet. I don't know how it would handle in such a situation.
I have a problem.
My problem is that every time I make changes to my node.js server code, I have to restart the entire thing to see the results.
Instead of this, I remember seeing something about being able to pipe chrome directly into the server's source code, and "Hot edit" it. That is to say, changes to the code immediately take effect and the server keeps runnings.
I hope that I am being clear.
It would be a real time saver to directly edit code (especially for small things) while the server is actually running and have it instantly take effect.
Does anyone know how to do this?
See my answer to my own question that answers this question: https://stackoverflow.com/a/11157223/813718
In short, there's a npm module named forever which does what you want. It can monitor the source files and restart the node instance when a change has been detected.
I do not quite understand the pipe-to-chrome part... But there seems to be a node module which listens to changes of userdefined files and restarts the server automatically:
How can I edit on my server files without restarting nodejs when i want to see the changes?
https://github.com/isaacs/node-supervisor
Yes, there is such thing.
Just take advantage of the evil-so-called eval() function of Javascript.
(You might need something like websocket to connect with the server and alert it about the change)
I am on the half-way of implement the same feature, but there are a lot of things to consider if you want to reserve the server states (current values of variables for example)
ABOUT THE pipe-to-chrome part
May be this was what you mentioned?
https://github.com/node-inspector/node-inspector/wiki/LiveEdit
I am a mostly front end JavaScript developer looking to get more into server side development with Node.js. My current level of understanding of Node is decent, ie. I understand what it is, how to install, and basics of getting it running. What I am interested with now is help / advice on what what to do next in order to get larger applications built. What are best practices / frameworks for getting an HTTP server up and running to serve my front end code (HTML, CSS, and JS). I know that there are things like soket.io once you have the app running for communication with the server but it is the first step I am interested in. Also what are best practice for organizing code on the server (separating out front end and back end files on the server). I would also be interested in any advice on getting a database setup and interfacing with it. I think for now I will wait for anything to do with deploying but eventually I will be looking into that.
I know this is a lot and I'm not looking for anyone to answer all this just some help getting pointed in the right direction for the point that I am at right now. I am also not apposed to paying for an material (as long as it is not crazy expensive) so if you have written any books you think that would help someone at my level please point me to it. As always a huge thanks to anyone who thinks they can help me out.
I would recommend you the Express JS framework. It's easy, powerful, and has awesome documentation.
I would definitely use express.js and mongoose to connect to mongodb to save data. I would not start with socketios until you clearly understand how nodejs and its callback mechanisms work. It gets complex and confusing if you do not understand that properly.
Checkout this post.
Looking for a reference nodejs, expressjs & mongodb app to use as template
If you're new to server-side development, I would suggest you start with one of the web frameworks, something such as express.
I would also recommend Underscore.js for writing cleaner more concise JavaScript. If you're planning a frontend of any significant complexity I would throw in Backbone.js to help structure the application. And if you're not sure about server side templating I have had a very positive experience with Jade.