Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all processes are killed if one process exits #167

Open
jmcantrell opened this issue Oct 4, 2020 · 5 comments
Open

all processes are killed if one process exits #167

jmcantrell opened this issue Oct 4, 2020 · 5 comments

Comments

@jmcantrell
Copy link

I first noticed this when implementing a "release" task in my procfile for a heroku app.

https://devcenter.heroku.com/articles/release-phase#specifying-release-phase-tasks

According to that document, the Procfile spec should be ok with having a short-lived process run alongside a long-lived one. I've not used any other implementation of foreman, and I'm not sure which one is being used on heroku.

I can see here that a killall signal is being emitted whenever a child process exits. It seems intentional, but I'm trying to understand why that would be the desired behavior.

https://github.com/strongloop/node-foreman/blob/master/lib/proc.js#L50-L54

My test case is as follows:

In Procfile:

release: node release.js
server: node server.js

In release.js:

console.log("running release task");

In server.js:

const net = require("net");
const server = net.createServer(() => {});
server.listen(0, () => console.log("server listening"));
process.on("SIGINT", () => process.exit());

And see that all processes are killed when running nf start. If the release process is removed, you'll notice that the server is not killed.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 25, 2020
@jmcantrell
Copy link
Author

I wasn’t able to find anything in the documentation describing this behavior. Is this expected?

@stale stale bot removed the wontfix label Dec 27, 2020
@hedinfaok
Copy link

@jmcantrell I don't maintain this package, but for anyone else out there that wants to use this package and follow the pattern that Heroku is using, here you go.

Looking at https://devcenter.heroku.com/articles/release-phase#specifying-release-phase-tasks, it looks like Heroku altered the Procfile format to include a specific process that runs only during the release phase on their platform. This breaks the idea behind the Procfile, which includes only long-running processes. If any of those processes exists, all processes exit. Why? So you can fix the reason why the service quit :)

To mimic the Heroku experience, you need to include each process in the Procfile in your command line. Given the following Procfile (which builds off of your example):

release: node release.js
server: node server.js
redis: /usr/bin/env redis-server
mongo: /usr/bin/env mongod

For your example, above, it would look like ./node_modules/.bin/nf start server redis mongo. This command will start your server, redis, and mongo processes and display colorful output in your terminal.

When you want to invoke the release process/command, you would run ./node_modules/.bin/nf run release.

Throw those in your yarn scripts or somewhere convenient.

References:

@stale
Copy link

stale bot commented Jul 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 21, 2021
@romgrk-comparative
Copy link

ping @slnode @rmg ?

@stale stale bot removed the wontfix label Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants