question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forever does not kill child process when used with -c

See original GitHub issue

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!

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
AntJanuscommented, Aug 26, 2015

@ericprieto babel/register allows you to use babel in subsequent required files. So, let’s say you create a start.js file which will be your new app starting point, add this to it:

require('babel/register'); //
require('./app.js'); //or whatever file, this is where the root of your app is

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

1reaction
roy-jcommented, Feb 4, 2016

Seems like

npm install kexec

just works

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forever does not kill child process when used with -c #687
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 ......
Read more >
Child process lives forever - Stack Overflow
I've made a child process management library where the parent process and the child process are monitored due a bidirectional WCF pipe.
Read more >
wait() — Wait for a child process to end - IBM
Suspends the calling process until any one of its child processes ends. More precisely, wait() suspends the calling process until the system obtains...
Read more >
How kill child process without read() hanging in the parent ...
There is an external program I'm calling from within my C/C++ program, by using fork() and execl(), and also redirecting stdio with dup2() ......
Read more >
Chapter 1. introduction to processes - linux-training.be
When starting a new bash you can use echo to verify that the pid from before is the ppid of the new shell....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found