railwayapp / nixpacks

App source + Nix packages + Docker = Image
https://nixpacks.com
MIT License
2.33k stars 222 forks source link

SIGINT not passed to application #1032

Open JakeCooper opened 6 months ago

JakeCooper commented 6 months ago

Is there an existing issue for this?

Describe the bug

SIGINT does not pass to container

To reproduce

Build the following

import { setTimeout } from "timers/promises";

const b = async () => {
    console.log("IN");
    process.on("SIGINT", () => {
        console.log("[ ⚡️ ] SIGINT received, shutting down");
    });

    process.on("SIGTERM", () => {
        console.log("[ ⚡️ ] SIGTERM received, shutting down");
    });

    process.on("uncaughtException", (err) => {
        console.log("[ ⚡️ ] Uncaught exception", err);
    });

    console.log("Loop init'd. Waiting...");
    await setTimeout(5000000);
}

b()

Run it

Try to SIGINT it

Expected behavior

SIGINT is processed

Environment

All environments

JakeCooper commented 6 months ago

Seems to be because we have a /bin/bash entrypoint

https://stackoverflow.com/questions/34441975/sigterm-does-not-reach-node-script-when-docker-runs-it-with-bin-sh-c

dush-t commented 6 months ago

Is this issue still up? Would like to attempt a fix.

coffee-cup commented 5 months ago

Is this issue still up? Would like to attempt a fix.

Yes this is still an issue. Would love a PR to fix it

dush-t commented 5 months ago

Alright, I'll attempt one.

dush-t commented 5 months ago

Unable to reproduce this. The SIGINT signal is, in fact, passed to the container upon running the example provided by @JakeCooper in the issue description.

I'm using Docker v4.26.1 on MacOS Monterey on an ARM macbook. Could you provide a more definitive way to reproduce this? What platform are you testing on, and what docker version are you using?