Docker SIGTERM does not ship to node.js / coffee app when run with flags

I set listeners in my application to catch SIGTERM, SIGINT and SIGUSR2:

# kill
process.on 'SIGTERM', ->
    killExecutors 'SIGTERM'

# ctrl + c
process.on 'SIGINT', ->
    killExecutors 'SIGINT'

# nodemon signal
process.on 'SIGUSR2', ->
    killExecutors 'SIGUSR2'

It works as expected. When I run it inside the docker instance:

FROM node:4.4.7

MAINTAINER Newborns <newborns@versul.com.br>

COPY . /src

EXPOSE 7733

WORKDIR /src
RUN npm install

CMD ["./node_modules/.bin/coffee", "feeder.coffee"]

Everything works perfectly. BUT when I add the node flag to the execution

FROM node:4.4.7

MAINTAINER Newborns <newborns@versul.com.br>

COPY . /src

EXPOSE 7733

WORKDIR /src
RUN npm install

CMD ["./node_modules/.bin/coffee", "--nodejs", "--max_old_space_size=384", "feeder.coffee"]

he stops capturing signals. I tried changing the exec CMD form to

CMD ./node_modules/.bin/coffee --nodejs --max_old_space_size=384 feeder.coffee

but still not working. What changes are made with and without flags?

EDIT:

Actually, what happens is that docker starts one process when flags are not transmitted

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  4.2  1.0 960940 85424 ?        Ssl  20:21   0:01 node ./node_modules/.bin/coffee feeder.coffee
root        16  0.1  0.0  20220  2884 ?        Ss   20:22   0:00 bash
root        20  0.0  0.0  17500  2064 ?        R+   20:22   0:00 ps -aux

and two processes when flags are passed

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  0.3 707704 25272 ?        Ssl  20:17   0:00 node ./node_modules/.bin/coffee --nodejs --max_old_space_size=384 feeder.coffee
root        10  1.7  1.1 965900 90068 ?        Sl   20:17   0:01 /usr/local/bin/node --max_old_space_size=384 /src/node_modules/.bin/coffee feeder.coffee
Question

: why?

+4
source share
1 answer

TL; DR Javascript coffee, node, Docker.

require('coffee-script').register();
require('./whatever.coffee').run();

node --max_old_space_size=384 app.js

...


PID 1 . PID 1 ( init) .

  • init , .
  • init, .

, , .


coffeescripts --nodejs

, coffee node, --nodejs, .

( osx). A SIGINT SIGTERM , coffee, , ( ).

process.on 'SIGTERM', -> console.log 'SIGTERM'
process.on 'SIGINT', -> console.log 'SIGINT'

cb = -> console.log "test"
setTimeout cb, 5000

ctrl - c, . .

$ coffee --nodejs --max_old_space_size=384 block_signal_coffee.coffee 
^C
SIGINT
$ <5ish second pause> test

5 test.


coffee --nodejs

, coffee , . , , .

quirk coffee --nodejs, Docker, , Docker. ( fork) , , . , .

javascript , runit supervisor, .

+4

Source: https://habr.com/ru/post/1650229/


All Articles