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

Cannot get process signal in docker #204

Open
hcfw007 opened this issue Jan 10, 2023 · 3 comments
Open

Cannot get process signal in docker #204

hcfw007 opened this issue Jan 10, 2023 · 3 comments

Comments

@hcfw007
Copy link

hcfw007 commented Jan 10, 2023

example:

async function main() {
  await new Promise(resolve => {
    setTimeout(resolve, 1000 * 60)
  })
}

const signals = [
  'SIGHUP',
  'SIGINT',
  'SIGTERM',
  'SIGQUIT',
  'SIGABRT',
  // 'SIGKILL',
  'SIGUSR1',
  'SIGUSR2'
]

for (const signal of signals) {
  console.log(`adding listener for signal ${signal}`)
  process.on(signal, () => {
    console.log(`process received a ${signal} signal`)
    process.exit(1)
  })
}

main()

It will log signal received if I use node to run in a docker container, however no siganl will be caught if I use bytenode to run in a docker container. (for docker stop, docker restart or docker-compose up -d. docker kill will work).

dockerfile:

FROM node:16.10.0-alpine3.11

RUN apk -u add --no-cache python3 bash
RUN npm install -g

WORKDIR /app

COPY ./index.js index.js
RUN bytenode -c ./index.js
CMD bytenode ./index.jsc
@OsamaAbbas
Copy link
Collaborator

Yeah, that is a bug in the cli.js file of bytenode. I will fix it soon.

For a workaround, run bytenode like this:

node -r bytenode ./index.jsc instead of bytenode ./index.js.

This should take care of your signal issue.

@hcfw007
Copy link
Author

hcfw007 commented Jan 10, 2023

Works like a charm. Cheers

@OsamaAbbas
Copy link
Collaborator

I tried to replicate your issue, but I cannot. No signal will be caught whether I run node or bytenode in docker.

Could you please explain in more details how do you catch or log the signals? My experience with docker is next to non-existent.

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

2 participants