éçºä¸ã«ããã°ã©ã ãåºã¾ã£ãæã« kill ããã»ã¹ID
ã£ã¦æã£ããã¨ãããæ¹ã¯å¤ããã¨æãã¾ã
åãããã§ã kill ã³ãã³ãã¯ããã»ã¹ãå¼·å¶çµäºããããã®ã³ãã³ãã ã¨æã£ã¦ãã¾ãã
ã§ãã puma ã®ãã°ãã¼ãã¼ããè¨å®ãã¦ããæã« kill -HUP
ã£ã¦åºã¦ãã¦ãªãã ããï¼ã£ã¦ãªãã¾ãã
ããï¼ãã°ãã¡ã¤ã«ãæ¡ãç´ãã®ã« kill
使ãã®ï¼ï¼ããã»ã¹ãæ¢ããããªãã¦æã£ã¦ãªããï¼ï¼ï¼ã¿ãããª
ãªã®ã§ã¡ããã¨èª¿ã¹ã¦ã¿ã¾ãã
TL;DR
- kill ã³ãã³ãã¯ããã»ã¹ã«å¯¾ãã¦ãã·ã°ãã«ããéä¿¡ããããã®ã³ãã³ã
- ã·ã°ãã«ã¯ããã»ã¹ãããã»ã¹å¤ã§ã®ã¤ãã³ãã«å¯¾ãã¦å¯¾å¿ããããã®æ©æ§
- ã·ã°ãã«ã«ã¯å®ç¾©ããã£ã¦ãããã¨ã«ããã©ã«ãåä½ããã
- ã·ã°ãã«ã®åä½ã¯ä¸æ¸ããããã¨ãå¯è½
ä»åã®ã·ãã¥ã¨ã¼ã·ã§ã³
logrotate 㧠puma ã®ãã°ãã¡ã¤ã«ããã¼ãã¼ã·ã§ã³ããããã¨ããç¶æ³ã§ãã
ãªã®ã§ãããããã¨ã°ã°ã£ã¦ä¸è¨ã®è¨å®ããã¾ãã
lastaction
puma_pid=/tmp/pids/puma.pid
test -s $puma_pid && /usr/bin/kill -HUP "$(cat $puma_pid)"
endscript
ãã㯠logrotate ããã°ãã¡ã¤ã«ãåãæ¿ããå¾ã«è¡ãå¦çã§ã
ããããããªã㨠puma ããã°ãåãåºããã¨ãã§ããªããªã£ã¦ãã¾ãã¾ã
ä»åã®ãã¢ã¯ kill -HUP
ã§ãã
puma ãæ¢ããããããããªãï¼ãã°ãåãæ¿ãããï¼ã®ã« kill
ãã¦ã¾ã
ãããè¬ã® -HUP
æå®ããã¦ã¾ã
ã©ããããã¨ã
kill ã³ãã³ãã®æ©è½ã«ã¤ãã¦
kill ã³ãã³ãã¯ããã»ã¹ãå¼·å¶çµäºããããã®ã³ãã³ãã ã¨æã£ã¦ãã¾ããããéãé°å²æ°ãæãã¾ã
ãªã®ã§ã¡ãã㨠kill ã³ãã³ãã® man ãè¦ã¾ãã
kill ã³ãã³ãã¯ãæå®ããã·ã°ãã«ãæå®ããããã»ã¹ã¾ãã¯ããã»ã¹ã°ã«ã¼ãã¸éããã·ã°ãã«ãæå®ãããªãå ´åãTERMã·ã°ãã«ãéãã
https://linuxjm.osdn.jp/html/util-linux/man1/kill.1.html
ããã»ã¹ã®å¼·å¶çµäºãªãã¦ä¸è¨ãæ¸ãã¦ã¾ãã
~~ ãªãã¦ç´ããããã³ãã³ãåã§ãããã ~~
kill ã³ãã³ãã¯ã·ã°ãã«ãããã»ã¹ã«éãã³ãã³ãã§ã
ãã·ã°ãã«ãã¨ãããã»ã¹ãã¨ãããã¼ã¯ã¼ãã2ã¤åºã¦ãã¦ãã¾ãã
ããã»ã¹ã¯ããããã°ã©ã ãæãã¨ç解ãã¦ããã¾ã
ã·ã°ãã«ã£ã¦ãªããã
ã·ã°ãã«ã¨ã¯
ãªãããã®ã¤ãã³ããèµ·ãã£ããã¨ãããã»ã¹ã«éç¥ããããã®æ©æ§ã§ã
ã¤ãã³ããåãåã£ãããã»ã¹ã¯ãã¤ãã³ãã®ç¨®é¡ã«ãã£ã¦ãªãããã®å¦çããã¾ã
åãåãå´ã®ããã»ã¹ã¯èªèº«ã®å®è¡ã¨ã¯å¥ã§åãåããã¨ãã§ãã¾ã
ã¤ã¡ã¼ã¸ã¯ Javascript ã® addEventListener
ãè¿ãã¨æãã¾ã
ãªãããã®ã¤ãã³ããçºçãããããã«å¯¾å¿ããé¢æ°ãå®è¡ããã¾ã
ä¾ãã°ä¸ã®å ´åã§ã
var select = document.querySelector('select') // L1
select.addEventListener('click', function() { // L2
console.log('clicked!') // L3
})
select.addEventListener('change', function() { // L5
console.log('changed!') // L6
})
ãªãããã®ã¤ãã³ããèµ·ãã£ãã㨠(L2) ãããã»ã¹ (L1) ã«éç¥ããããã®æ©æ§ã§ã
ã¤ãã³ããåãåã£ãããã»ã¹ã¯ãã¤ãã³ãã®ç¨®é¡ (L2, L5) ã«ãã£ã¦ãªãããã®å¦ç ( L3, L6 ) ããã¾ã
ã·ã°ãã«ãç»å ´ããå ´é¢
æ®æ®µã®éçºã§ã·ã°ãã«ã®éä¿¡ãæèãã¦ããªãæ¹ãå¤ããã¨æãã¾ã
ã§ããã以å¤ã¨ã·ã°ãã«ãéä¿¡ãã¦ããæ©ä¼ã¯æå¤ã¨ããã¾ã
ä¾ã«ããã kill
ããã®1ã¤ã§ã
ãªãã·ã§ã³ã« -KILL
ã -9
ãã¤ãã¦å®è¡ããã¨å¯¾è±¡ã®ããã»ã¹ã«å¯¾ã㦠SIGKILL
ã¨ããã·ã°ãã«ãéä¿¡ãã¦ãã¾ã
kill
ï¼ãªãã·ã§ã³ãªãï¼ ã®å ´å㯠SIGTERM
ã¨ããã·ã°ãã«ãéä¿¡ãã¦ãã¾ã
ã¾ã terminal ã§ãã使ã Ctrl-c
ãããã»ã¹ã«å¯¾ãã¦ã·ã°ãã«ãéä¿¡ãã¦ãã¾ã
Ctrl-c
ãå
¥åããã¨ããã»ã¹ã«å¯¾ã㦠SIGINT
ã¨ããã·ã°ãã«ãéä¿¡ããã¾ã
åãã Ctrl-z
㯠SIGTSTP
ãéä¿¡ãã¦ãã¾ã
ãã㯠javascript ã ã¨ãã©ã¦ã¶ä¸ã§ä½ãã®ã¢ã¯ã·ã§ã³ãèµ·ããæï¼ã¯ãªãã¯ã¨ãã¹ã¯ãã¼ã«ã¨ãï¼ãã¤ã¡ã¼ã¸ãã¦ãããã¨è¿ããã¨æãã¾ã
ãã®å ´åã¤ãã³ããã³ãã© console.log('clicked!')
ã¨ãããã¨ããã¯ã©ããªãã®ã§ãããã
ã·ã°ãã«éä¿¡å¾ã®æå
ããã©ã«ãã®æå
ã·ã°ãã«ãåãåã£ãããã»ã¹ã¯ããã®ã·ã°ãã«ã®ç¨®é¡ã«ãã£ã¦ãªã«ãããã®å¦çããã¾ã
åºæ¬çã«ã¯ã·ã°ãã«ãã¨ã«å®ç¾©ããã¦ããããã©ã«ãã®å¦çãè¡ããã¾ã
ä¸é¨ãç´¹ä»ããã¨ãããªã£ã¦ãã¾ã
ã·ã°ãã«ã®ç¨®é¡ | ããã©ã«ãã®åä½ | åè |
---|---|---|
SIGINT | çµäº | ãã¼ãã¼ãããã®å²ã込㿠(Interrupt) |
SIGTSTP | åæ¢ | terminal ããå ¥åãããæåæ¢ |
SIGKILL | çµäº | kill ã·ã°ãã« |
SIGTERM | çµäº | termination çµäºã·ã°ãã« |
SIGHUP | çµäº | terminal ã®ãã³ã°ã¢ãããå¶å¾¡ãã¦ããããã»ã¹ã®æ» |
http://linuxjm.osdn.jp/html/LDP_man-pages/man7/signal.7.html
ããã°ã©ã ãåæ¢ãããæã« Ctrl-c
ãæ¼ãã°ãããã¨ããã®ã¯ãããããã¨ã§ãã
ã¤ã¾ã Ctrl-c
ãæ¼ã㨠SIGINT
ã·ã°ãã«ãããã»ã¹ã«éä¿¡ãããããã©ã«ãã®æåã§ãããçµäºãå¦çãè¡ãããã§ã
ããã©ã«ãæåã®ä¸æ¸ã
SIGINT
ãåãåã£ãããã»ã¹ã¯çµäºå¦çãè¡ãã¾ãããããã¯ããã¾ã§ãããã©ã«ãã§å®ç¾©ãããæåã§ãããªãå¥ã®å¦çããããï¼ãã£ããï¼ãã¨ãã§ãã¾ã
ä¾ãã° less
ã³ãã³ãã®ã®å ´åã less
ãèµ·åãã¦ãã Ctrl-c
ãæ¼ä¸ãã¦ãããã»ã¹ã¯çµäºãã¾ãã
ããã¯ããã©ã«ãã®çµäºã¨ããæåãä¸æ¸ããã¦ããããã§ã
ã¤ã¾ããããã·ã°ãã«ã«å¯¾ãã¦ãªã«ãããã®ãã¯ãã®ããã°ã©ã ã®å®è£
ã«ãããã¨ãããã¨ã§ã
éã«ãããã°ã©ã ã¯ã·ã°ãã«ãåãåããã¨ã§å¤é¨ã®ä»»æã®ã¿ã¤ãã³ã°ã§è¦å®ã®åä½ãåãä»ãããã¨ãã§ãããã¨ãè¨ãã¾ã
javascript ã§ããã°ã form ã® submit ãããã¯ã㦠submit åã«ããªãã¼ã·ã§ã³ãæããçãªæåããããã®ã«ä¼¼ã¦ã¾ãã
var form = document.querySelector('form')
form.addEventListener('submit', function(evt) {
if (do_validations() == false) {
evt.preventDefault();
}
})
è£è¶³ã§ãããã·ã°ãã«ã¯ãã£ãããã以å¤ã«ãããã¯ãããç¡è¦ãããã¨ãã§ãã¾ã
ãã ã SIGKILL
㨠SIGSTOP
ã¯ãã£ããããããã¯ãç¡è¦ãããã¨ã¯ã§ãã¾ãã
kill -HUP
ã®è§£èª
ãã¦ã話ãæ»ãã¦ä»åã®ã·ãã¥ã¨ã¼ã·ã§ã³ kill -HUP
ããªããªã®ãã¨ãã件ã§ã
å
·ä½çã«ã¯ puma ã®ãã°ãã¡ã¤ã«ã«å¯¾ãã logrotate ã®ä¸ã§ã puma ã«ãã°ãã¡ã¤ã«ãæ¡ãç´ãã¦ãããããã« kill -HUP {puma ã®ããã»ã¹}
ããã¾ã
ã¾ã kill -HUP
ã§ã
kill
ã³ãã³ãã使ã£ã¦ puma ã«å¯¾ã㦠SIGHUP
ã®ã·ã°ãã«ãéä¿¡ãã¦ãã¾ã
SIGHUP
ã¯åè¿°ã®éã terminal ã®ãã³ã°ã¢ãããå¶å¾¡ãã¦ããããã»ã¹ã®æ»ã表ããããã©ã«ãã§ã¯ããã»ã¹ã¯çµäºãã¾ã
ã§ããå®éã«ã¯ puma ã®ããã»ã¹ã¯çµäºããªãã®ã§æå³ä¸æã§ã
ãªã®ã§è½ã¡çã㦠puma ã® wiki ãåç
§ãã¾ããã
Puma cluster responds to these signals:
HUP
reopen log files defined in stdout_redirect configuration parameter.
puma 㯠HUP
ãåãåãã¨ãã°ãã¡ã¤ã«ããªãªã¼ãã³ãã¾ã
ã¨ããã¾ã
ã¤ã¾ã puma 㯠SIGHUP
ããã£ãããã¦ãããã»ã¹ã®çµäºããã代ããã«ãã°ãã¡ã¤ã«ãæ¡ãç´ãã¦ããã¾ã
ã¨ãããã¨ã§ãããã§ç解ã§ãã¾ããã
ãlogrotate ã®ä¸ã§ puma ã«å¯¾ã㦠SIGHUP
ã·ã°ãã«ãéä¿¡ãããã¨ã§ã
puma ã SIGHUP
ã·ã°ãã«ã«å¯¾ãã¦ç¬èªã«å®ç¾©ããããã°ãã¡ã¤ã«ããªãªã¼ãã³ãããã¨ããåä½ããããã
ã¨ããè¨å®ã§ãã
è£è¶³
ã·ã°ãã«ã®å¤ã«ã¤ãã¦
ã·ã°ãã«ã«ã¯ååã¨ã¨ãã«å¤ãå²ãæ¯ããã¦ãã¾ã
ã·ã°ãã«ã®ç¨®é¡ | å¤ | ããã©ã«ãã®åä½ | åè |
---|---|---|---|
SIGHUP | 1 | çµäº | terminal ã®ãã³ã°ã¢ãããå¶å¾¡ãã¦ããããã»ã¹ã®æ» |
SIGINT | 2 | çµäº | ãã¼ãã¼ãããã®å²ã込㿠(Interrupt) |
SIGKILL | 9 | çµäº | kill ã·ã°ãã« |
SIGTERM | 15 | çµäº | termination çµäºã·ã°ãã« |
kill
ã³ãã³ãã使ã£ã¦ããã»ã¹ãåæ¢ãããã¨ãã« kill -KILL
ã¨ããã kill -9
ã¨ãããããã¨æãã¾ã
kill
ã³ãã³ãã¯ãªãã·ã§ã³ã§ã·ã°ãã«åãã·ã°ãã«å¤ãåãåãã¾ã
ãªã®ã§ -KILL
㨠-9
ã¯ã©ã¡ãã SIGKILL
ãéä¿¡ããã®ã§åãæåã«ãªãã¾ã
ã·ã°ãã«ããã£ãããã
C è¨èªã§ã·ã°ãã«ããã£ããããããã«ã¯ sigaction
é¢æ°ã使ãã¾ã
https://linuxjm.osdn.jp/html/LDP_man-pages/man2/sigaction.2.html
signal
é¢æ°ããããã§ãããæ´å²çèæ¯ããéæ¨å¥¨ãªããã§ã
ruby ã®å ´å㯠Signal.#trap
ã§ãã£ããã§ãã¾ã
https://docs.ruby-lang.org/ja/latest/method/Signal/m/trap.html
puma ã ã¨ãããªæã
https://github.com/puma/puma/search?q=signal+trap&unscoped_q=signal+trap
nginx ã® logrotate ã®å ´å
puma 㧠logrotate ãããããã« nginx ã§ã logrotate ãã¦ããã®ã§ã¤ãã§ã«èª¿ã¹ã¦ã¿ã¾ãã
ec2 㧠nginx ãã¤ã³ã¹ãã¼ã«ãã㨠logrotate ãèªåã§è¨å®ããã¦ãã¾ãã
postrotate
/etc/init.d/nginx reopen_logs
endscript
ããã ã¨ãããã«ããã®ã§å ¬å¼ãµã¤ããåç §ããã¨
NGINX will re-open its logs in response to the USR1 signal.
$ kill -USR1 `cat master.nginx.pid`
https://www.nginx.com/resources/wiki/start/topics/examples/logrotation/
ãããããã¾ãã
SIGUSR1
ã·ã°ãã«ãéä¿¡ãã¦ãã¾ã
SIGUSR1
ã¯ååºã§ãããããã©ã«ãã®åä½ã¯ãçµäºãã§ããã¯ãã¦ã¼ã¶ã¼å®ç¾©ã·ã°ãã«1ãã¨ããã·ã°ãã«ã§ã
好ãã«ä½¿ã£ã¦ããããã£ã¦æãã§ããã
nginx ã§ãã°ãã¼ãã¼ãããå ´å㯠puma ããç´ ç´ã§ã«å¥½ãã«ä½¿ã£ã¦ãããã·ã°ãã«ãä»ãã¦ãã°ãã¡ã¤ã«ãæ¡ãç´ãã¦ãããã¿ããã§ã
unicorn ã® logrotate ã®å ´å
puma 㨠nginx ãè¦ã¦ããã®ã§ã¤ãã§ã« unicorn ãè¦ã¦ã¿ã¾ã
å ¬å¼ãµã¤ãã®ã·ã°ãã«ãã³ããªã³ã°ã®é ã«æ¸ãã¦ããã¾ãã
USR1 - reopen all logs owned by the master and all workers See Unicorn::Util.reopen_logs for what is considered a log.
https://bogomips.org/unicorn/SIGNALS.html
ã¨ãããã¨ã§ nginx ã¨åãã USR1
ã·ã°ãã«ãéä¿¡ããã°è¯ãããã§ãã
ã¾ã¨ã
ã·ã°ãã«ã¨ kill
ã³ãã³ãã«ã¤ãã¦èª¿ã¹ã¦ã¿ã¾ãã
åºä¼ãæ©ä¼ã¯å°ãªãã£ãããªããé£ãããã ã£ãã®ã§ãªãã¨ãªãã§æµãã¦ãã¾ã£ã¦ãã¾ããããã¡ããã¨èª¿ã¹ã¦ã¿ãã°ãªãã¦ãã¨ã¯ãªãã£ãã§ã