forever: Forever does not kill child process when used with -c
I’m trying to run Babel with forever which basically means that I run the following command:
forever start -c "babel-node app.js --experimental --harmony"
Note that “babel-node” is a small wrapper to Node and is supposed to (theoretically) work identically and accept identical commands. Anyways, when the app crashes, forever tries to restart it by killing the process and starting another one.
The problem is, it doesn’t kill the process, and invokes the babel-node app.js
command which creates another instance of Node (which crashes due to port in use
error) and it invokes the command again and again.
If anyone knows how to run Babel (other than via the require hook) along with Forever, let me know!
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 16 (1 by maintainers)
@ericprieto
babel/register
allows you to use babel in subsequent required files. So, let’s say you create astart.js
file which will be your new app starting point, add this to it:Make sure you have babel installed locally via
npm install babel --save
so that the library can be required. The library compiles code at runtime rather than beforehand.babel-node
is basically a neat wrapper for this functionality (compiles at runtime as well).In the start file, you can’t use ES6; however, any file down the road can be. So
app.js
can be fully ES6 with imports, exports, etc.Read the docs on it
Seems like
npm install kexec
just works
I ended up using the require hook. In the end, it’s not that troublesome to add a
main.js
file with: