Skip to content

all processes are killed if one process exits #167

Open

Description

@jmcantrell

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.

Activity

  1. stale commented on Dec 25, 2020

    @stale

    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.

  2. jmcantrell commented on Dec 27, 2020

    @jmcantrell
    Author

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

  3. hedinfaok commented on Apr 17, 2021

    @hedinfaok

    @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:

  4. stale commented on Jul 21, 2021

    @stale

    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.

  5. romgrk-comparative commented on Oct 15, 2021

    @romgrk-comparative

    ping @slnode @rmg ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions