Comments (11)
Thanks for taking the time to look into this!
Actually we've had a brief "adventure" trying to use npm start
a few months ago, see #7, #10 and #11.
As far as I remember, there were 2 main problems:
- We also need to be able to properly stop/restart the app, and I remember @AlexChesters bumped into and issue (see #10);
- The additional process is taking up memory during the entire application life-cycle. While ~30MB is definitely not an issue on a development machine, the amount of memory we can use in the application cartridge is limited. But the benefits may outweigh the costs, I guess we'll just have to test and see how it behaves.
I think we might be able to make it work in the end, so I'll spin up a test app and run some tests when I find the time, hopefully over the next couple of days.
Meanwhile, any feedback/help is, of course, appreciated! :-)
from openshift-cartridge-nodejs.
On the issue of properly start/stop/restart control of the application, I would suggest saving the process ID (PID) of the process in a (PID) file that we can use to query its status. Since it might be safe to assume that the actual process started by the control script in the cartridge is that of a process manager such as supervisord, forever, nohup, etc., the PID would not change even when the managed application process crashes and is restarted. All we would have is the PID of the process manager (which obviously (?), is the parent of any application processes it manages). I do not clearly know how this would affect scaling with gears, we would require more research into that.
The other issue of npm hogging memory is daunting. First, npm does eat up valuable memory (on my machine, when my node_modules/
gets larger in size, npm gets so slow and heavy, I end up using nice
). But I see most PaaS using npm start
for starting their applications. While this is no validation that it is the correct way to do it, it would be our best interest to understand how they handle the memory issue.
from openshift-cartridge-nodejs.
I guess PaaS are generally defaulting to npm start
for convenience, not efficiency. For instance,Heroku does it only if a Procfile
is not present in the root of your application.
"It would be our best interest to understand how they handle the memory issue" - I suspect they don't, but you can always buy more gears ;-)
I never considered the fact that the amount of memory taken by npm start
is directly related to the size of node_modules
, but now that you mentioned, it makes total sense.
That being said, maybe we consider adding node_modules/.bin
to $PATH
on cartridge install instead of using npm start
to start the application.
What do you think?
from openshift-cartridge-nodejs.
I have actually started reading through the npm source code, noting the setup functions it goes through when running scripts. Mostly cause I'm not very sure how the size affects the process so much!
I have always thought Heroku have their shit together, better than these other PaaS. But I guess building great s/w is quite hard, you know!
While modifying $PATH
would certainly solve my primary issue (in this thread), this same issue would crop up later should we realize that npm start
does more! We will end up re-implementing the functionality all over again (and am a lazy coder!!!).
But we could modify $PATH
and clearly state in the README that we are not using npm start
. A link to this discussion would help pull more people into it and hear different perspectives.
from openshift-cartridge-nodejs.
Just added node_modules/.bin
to $PATH
in this commit and a link to this discussion in the README as suggested. You should now be able to things like forever app.js
in your package.json
scripts without having to prefix them with node_modules/.bin
. Unfortunately you'll have to redeploy your application, since custom cartridges can't autoupdate.
I'm going to close the issue for now, but we can always reopen it if necessary.
Thanks again for your feedback and support.
from openshift-cartridge-nodejs.
Nice job! Hoping to improve this catridge in the future. 👍
from openshift-cartridge-nodejs.
Can we also include these predefined scripts?
https://docs.npmjs.com/misc/scripts#description
pretest, test, posttest: Run by the npm test command.
prestop, stop, poststop: Run by the npm stop command.
prestart, start, poststart: Run by the npm start command.
prerestart, restart, postrestart: Run by the npm restart command.
from openshift-cartridge-nodejs.
@Qusic - won't have time to look at this and do proper implementation and tests until the next week.
Feel free to try your hand if you have time - you'll probably want to look at bin/control.
I can imagine when you'd like to call pre/post stop, start & restart, but I have no idea where - in terms of OpneShift-specific commands - to call pre/post test.
from openshift-cartridge-nodejs.
So @Qusic kinda saw the future for me. I needed to make it support stop (see #57). The **pre** and **post** scripts will have to be invoked immediately before and after the corresponding scripts.
@Qusic Did you get to work on this?
from openshift-cartridge-nodejs.
This has been really daunting for me, as i have a prestart script setup to build my databases and tables automatically. But to my wildest suprise npm start. Never get called according to you guys, whats the roadmap from here? ... Are you implementing it at a later time or what are the other best practices?
from openshift-cartridge-nodejs.
Until we are able to implement the pre and post scripts, you may want to use an action hook, in particular .openshift/action_hooks/pre_start
.
from openshift-cartridge-nodejs.
Related Issues (20)
- How to disable strict-mode HOT 1
- support "stop" script HOT 5
- Instructions on how to set up HOT 3
- Number of installs/deployments
- Updating an already deployed app HOT 3
- Constant error during push - Failed to execute: 'control stop' HOT 3
- failed to install github modules?
- No ".openshift" directory HOT 2
- Failed to execute: 'control start' for ... HOT 5
- Problem while creating my application (rhc command line) HOT 4
- HTTP error 503 while node.js is booting on a idle gear HOT 4
- Constant issue -- Cannot read property 'stop' of undefined HOT 1
- Problem when deploying? HOT 1
- Failed to execute control start HOT 1
- update current running applications NODE.js cartridge HOT 5
- Sorry for being inactive lately
- Add create app logo
- Log files location? HOT 3
- Looking for maintainers HOT 2
- Missing enviroment variables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openshift-cartridge-nodejs.