all processes are killed if one process exits
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.
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.
I wasn’t able to find anything in the documentation describing this behavior. Is this expected?
@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:
- https://github.com/ddollar/foreman
- http://blog.daviddollar.org/2011/05/06/introducing-foreman.html
- https://ddollar.github.io/foreman/#PROCFILE
- https://github.com/ddollar/foreman/wiki
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.
ping @slnode @rmg ?