unicornã®preload_app
unicornã®è¨å®ãpreload_appãã«ã¤ãã¦ã
ãã£ããã¨ããworkerã®ã¢ããªã±ã¼ã·ã§ã³ã®å
èªã¿ãã®è¨å®ãããã
ãã®ãµã¤ãã«è©³ãã説æããã£ãã®ã§è¨³ãã¦ã¿ããè±èªã¯è¦æãªã®ã§æªããããªãã¨ãªãé°å²æ°ã¯åã£ã¦ãæ°ãããã
http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-preload_app
Enabling this preloads an application before forking worker processes.
workerãforkããåã®ã¢ããªã±ã¼ã·ã§ã³ã®å èªã¿ãæå¹ã«ãã¾ãã
This allows memory savings when using a copy-on-write-friendly GC
ããã¯ãcopy-on-write-friendlyã«ç¸æ§ã®è¯ãç°å¢ã§ã¯ãã¡ã¢ãªãç¯ç´ã§ãã¾ãã
but can cause bad things to happen when resources like sockets are opened at load time by the master process and shared by multiple children.
ããããsocketã®ãããªãªã½ã¼ã¹ã¯masterã«ãã£ã¦ãã¼ãæã«éãã¦è¤æ°ã®children(worker)ã§å ±æããã¦ããã¨ãã«æªããã¨ãèµ·ããå¯è½æ§ãããã¾ãã
People enabling this are highly encouraged to look at the before_fork/after_fork hooks to properly close/reopen sockets. Files opened for logging do not have to be reopened as (unbuffered-in-userspace) files opened with the File::APPEND flag are written to atomically on UNIX.
ãããæå¹ã«ãããªããbefore_forkãããã¯after_forkã§socketãã®é©åãéãç´ããã¨ããããããã¾ãã
ã§ããã°ãã¡ã¤ã«ã¯UNIXã«ãã£ã¦ã¢ãããã¯ã«æ¸ãè¾¼ã¾ããã®ã§åé¡ãªãã
In addition to reloading the unicorn-specific config settings, SIGHUP will reload application code in the working directory/symlink when workers are gracefully restarted when preload_app=false (the default).
preload_app=falseã®æã«HUPã§unicornã®åèµ·åãæ£å¸¸ã«è¡ãããå ´åãè¨å®ã¨ã¢ããªã±ã¼ã·ã§ã³ããªãã¼ããããªãã¼ãããããã®ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ãåãæ¿ããã¾ãã
â preload_appã®è¨å®ã«ããSIGHUPã§ã®åèµ·åæã®æåã®éã
preload_appã®è¨å®ã«ãã£ã¦ãSIGHUPï¼workerã®å¦çã®å®äºããã£ã¦åèµ·åï¼ãéã£ãã¨ãã«æåãéã£ã¦ããã
true
- unicornã®è¨å®ï¼åèªã¿è¾¼ã¿ããã
- ã¢ããªã®ãªãã¼ãï¼ãããªããã¢ããªã¯ãã¹ã¿ã§ãã¼ãæ¸ã¿ã®ãã®ã使ããã¢ããªããªãã¼ãããããã°ãSIGUSR2ãéã£ã¦æ°ãã¹ã¿&workerãç«ã¡ä¸ããæ¹æ³ãã¨ãã
- ãã¦ã³ã¿ã¤ã ï¼çºçããªãï¼ãã¹ã¿ã®ã¢ããªããã®ã¾ã¾ä½¿ãã®ã§ãworkerãããã£ãæããå¦çãå¯è½ï¼
false
- unicornã®è¨å®ï¼åèªã¿è¾¼ã¿ããã
- ã¢ããªã®ãªãã¼ãï¼ããã
- ãã¦ã³ã¿ã¤ã ï¼çºçãããï¼workerãããããã¢ããªããã¼ãããã®ã§ããã¼ãå®äºã¾ã§å¦çã§ããªãï¼
preload_appãfalseã«ããæã£ã¦ï¼
ããã¦preload_appãfalseã«ããæã£ã¦ãªãã ããã
preload_appãtrueã®æã®ãã¡ãªããã¯ã
ã»SIGUSR2ã§ã®åèµ·åã«ãªããæé çã«å¤å°è¤éï¼å¤ãmasterãå¾ã§è½ã¨ããªã©ï¼
âã§ãcapistranoçã§èªååå¯è½ãªç¯å²ã
ã»SIGUSRã§æ°ãã¹ã¿&workerãç«ã¡ä¸ããå ´åãä¸æçã«ãã¹ã¿&workerã®ã»ãããï¼ã»ããã§ããããã¡ã¢ãªçã«ä¸ç¬å¤§ãããªãäºããã
âpreload_appãfalseã®å ´åã¯workeræ°åã®ã¢ããªãã¡ã¢ãªã«ãã¼ãããããã ãããã£ã¡ã®æ¹ã大ãããªããã
ä½ãã®æ
å ±ã§ãSIGUSR2ãä¸å®å®ã¨ããäºãèãããã¨ã¯ãããã©ããã®ã¸ãã®äºæ
ãªã®ããªã
æ
å ±ã¨ã¤ã£ãã¿æ¬²ããã