ãªã¼ãã³ã½ã¼ã¹ã«ã³ãã¡ã¬ã³ã¹Hokkaido2015 jusç 究ä¼æå¹å¤§ä¼ããªãã»ã©Unixããã»ã¹ â Rubyã§Unixã®åºç¤ãå¦ã¼ããã®çºè¡¨è³æã§ãã https://www.ospn.jp/osc2015-do/modules/eguide/event.php?eid=11 åç»: â¦
#naruhounix ãèªãã ã æ£ç´ãããã»ã¹ï¼ããã§ããããªããåããã¤ããã¨ããã¬ãã«ã ã£ãã®ã§é常ã«åå¼·ã«ãªã£ãã Rubyã§æ¸ããã¦ããã®ããä½è¨ãªãã¨(Cã®ææ³ã¨ãä¾å¤å¦çã¨ã)ãã¤ãã¦ããªãã¦ç解ããããã æ¸ãæ¹ã¯ããããã¤ã¡ã¼ã¸ãç¥ãããããï¼ã¨ããã¿ã¤ãã®æ¹ã«ããããã éã«Rubyã®ä½è¨ãªãã¨(ãã®ãã¼ã¸ã§ã³ã§ã¯ä¿®æ£æ¸ã¿ã¨ã)ãã¤ãã¦ããã®ã§Rubyistå¯ãã§ãããã¨ã¯ããªããªãã ããã»ã¹ãforkãã¦ããªã½ã¼ã¹ã¯åãã¿ãããªã¨ããã¯ãã¤ã³ã¿çãªè§£éã ãã¨forkå¾ã¡ãã£ã¨ã§ãã¡ã¢ãªã®å 容ãå¤ãã£ããå ¨ã³ãã¼ã ã¨æã£ã¦ããã©å ¨ç¶éã£ã¦ãªãã¸ã§ã¯ãåä½ï¼(ãã®ã¸ããããµã)ã¨ãããæ¬å½ã«å¤ãã£ãé¨åã ãã³ãã¼ãããã¿ããã ã ä¾ãã°Railsã¢ããªã¨ãã¯ç«ã¡ä¸ããéã«å¤§éã®ãã¬ã¼ã ã¯ã¼ã¯ã®ã³ã¼ãã¨ã¢ããªã±ã¼ã·ã§ã³ã®ã³ã¼ããèªã¿è¾¼ãã§ããã®ã§æ°ç§ã¨ããããã ãã
å æ¥ISUCONãè¡ããã¦ããã ãã¯ã¯åºå ´ãã¦ãªãã¦ãTwitterãã観æ¦ãã¦ããã ãã ã£ããã ãã©isuconã¿ã°ãçºãã¦ããã¨ä»¥ä¸ã®ã¹ã©ã¤ããæµãã¦ããã ä»å2ä½ã ã£ãpixivãã¼ã ã®katatsuyãããisuconåã«ä½ã£ã¦ããç¥è³æãããã èªãã§ã¿ããããªãã»ã©ãåºåãµã¼ãã¼ã®æ§ç¯æã®è¦å´ãç¥è¦ãç´ æ´ãããã¾ã¨ã¾ã£ã¦ããã ã§ãã¹ã©ã¤ãã®æå¾ã®ã»ãã«ããããã®æ¸ç±ãè¨ããã¦ã¦ããã«ããªãã»ã©Unixããã»ã¹ - Rubyã§å¦ã¶Unixã®åºç¤ãããã£ãã®ã§è³¼å ¥ãã¦èªãã§ã¿ãã 親ããã»ã¹ãåããã»ã¹ãforkããã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ãã¾ã³ãããã»ã¹ããã¼ã¢ã³ããã»ã¹ãããã»ã¹ã°ã«ã¼ããã»ãã·ã§ã³ã°ã«ã¼ããã·ã°ãã«ãã¹ããªã¼ã ããã¤ããIPCãã½ã±ãããã³ãã¼ãªã³ã©ã¤ã ãããã®ç¨èªã®ä¸ã§èª¬æã§ããªãè¨èãããRubyã¨ã³ã¸ãã¢ã¯ãã®æ¬ãèªãã¨è¯ãã ã©ããUnixããã°ã©
toRuby & guRuby åºå¼µç ã§ã·ã°ãã«ã«ã¤ãã¦ãã£ã¦ãã®ã§ãé¢é£ãã¦æ¸ãã¦ã¿ã¾ãã ã©ã®ãããªæã«ã·ã°ãã«ãã³ãã©ãå®ç¾©ããã®ã ã©ã®ãããªæã«ã·ã°ãã«ãã³ãã©ãå®ç¾©ããã®ãã¨ãã話ãããã¾ããã UNIXã®ãã¼ã¢ã³ããã°ã©ã ã¯ãä½ãç±æ¥ãªã®ããããã¾ããããSIGHUP ã§è¨å®ãã¡ã¤ã«ã®åèªã¿è¾¼ã¿ãè¡ãã®ãæ £ç¿ã«ãªã£ã¦ãã¾ãã SIGHUP ã¯ããã©ã«ãåä½ã§ã¯ããã°ã©ã ãçµäºããã¦ãã¾ãã ããªã®ã§ãSIGHUP ã§ç¹å¥ãªå¦çãè¡ãããããã°ã©ã ã¯ã·ã°ãã«ãã³ãã©ãå®ç¾©ãã¦ãã¾ãã æ¬æ¥ SIGHUP ã¯ç«¯æ«ãçµäºããæã«ç«¯æ«ä¸ã§åãã¦ããããã°ã©ã ã«å¯¾ãã¦OSãçºè¡ããããã®ãã®ã§ãã ãã¨ãã°ã端æ«ã¨ãã¥ã¬ã¼ã¿ãéãã¦ã % sleep 9999 ã¨å®è¡ãã¦ãç¶æ ã§ç«¯æ«ã¨ãã¥ã¬ã¼ã¿ãéãã㨠sleep ããã»ã¹ã« SIGHUP ãéããã¾ããå¥ã®ç«¯æ«ãã strace
æ°äººã¨ã³ã¸ãã¢ã¨ã®èªæ¸ä¼ã§ã·ã°ãã«ã®è©±ãåºãæã«è²ã ç¥èãææ§ãªãã¨ã«æ°ã¥ããã®ã§èªãã ã(Spyglass ã«ã¤ãã¦ã¯ã¾ã 触ã£ã¦ããªã) 社å ã®å¥ã®èªæ¸ä¼ã«ããã®åèãèªããã®ããã£ããã ãã©ã å½æ Ruby ã UNIX ã«ã¤ãã¦ç¥èããªãéãããè±èªèªãã®ã«å°ãã¤ãã¿ããã£ãã ããããéä¸ããåå ãã¦ããªãã£ããè¦ãã¦ããã®ã¯ã¾ã³ãããã»ã¹ã®èªæã¨å 容ãéè¦ããã ã£ãã£ã¦ãã¨ãããã ä»åã¯è±èªå¦ç¿ããå 容ã®éç¿ãæ±ããã®ã§ã翻訳çãèªããã¨ã«ããã 以ä¸ã¯èªæ¸ææ³æã§ãã ããã»ã¹ãã«ã¼ãã«ãã·ã¹ãã ã³ã¼ã« ãã®æ¬ã¯ããã»ã¹ã¨ãããåãå·»ãæè¡ã«ã¤ãã¦ããããããªãåºç¤çãªãã¨ããæ¸ããã¦ãããUNIX ã«ã¤ãã¦ç¶ç¨ç¥èããªãã¨ãåé¡ãªãç解ãèªã¿é²ããããã èªèº«ã§ã¯ããã»ã¹ã¯è¦ªåé¢ä¿ãPIDã«ã¤ãã¦ç¥ã£ã¦ããç¨åº¦ã§ã5ç« ã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã 10ç« ã®çµäºã³ã¼ãã11ç«
2. èªå·±ç´¹ä»cuzicããã ã¼ãã£ããã¨èªã¿ã¾ããÃquzicãà cusicããªãã¡ã¯ã¿ãªã³ã° Ruby ã¨ãã£ã·ã§ã³ãã®èªæ¸ä¼ãè¨ç»ãã¦ãã¾ããï¼ JR å°¼å´é§ å¾æ©ï¼åï¼å°ç°å ¬æ°é¤¨ï¼æ¥ç¨æªå®Kent Beck è æè¿ JavaScriptã®åå¼·ä¸é¢æ°ã First-Class Object ã§ãããã2010/04/24第42å Ruby/Rails åå¼·ä¼@é¢è¥¿ 3. IO ã¯ã©ã¹ã¿ããªç¥ã£ã¦ããããï¼puts âHello, World!âSTDOUT ã STDIN 㯠IO ã®ã¤ã³ã¹ã¿ã³ã¹open(â/tmp/tempfileâ) do |io| ï½endãã¡ã¤ã«å ¥åºåã ãã§ãªãããããã¯ã¼ã¯å¦çãªã©ã«ã IO ã¯ã©ã¹ãå©ç¨ã2010/04/24第42å Ruby/Rails åå¼·ä¼@é¢è¥¿ 4. Ruby ã®IO ã¯ããããRuby ã®ã¹ã¬ããã¨ãã¾ãé£æºãããã¯ãã IO
Ruby ã§ã·ã§ã«ã®ãããªãã®ãä½ã£ã¦ã¿ãã¨ãRuby ã¨ã·ã§ã«ãã·ã¹ãã ã³ã¼ã«ã®ç解ãã§ãã¦ãç ä¿®ã®èª²é¡ã¨ãã«ããããããªããã¨10å¹´ãããåã«æã£ã¦ãã®ãããµã¨æãåºããã®ã§æ¸ãã¦ã¿ã¾ãã åºæ¬ ã·ã§ã«ã®åä½ãç°¡åã«èª¬æããã¨æ¬¡ã®ãããªæãã§ãã ããã³ãããåºå æ¨æºå ¥åããã³ãã³ãã©ã¤ã³ãèªã¿è¾¼ã èªã¿è¾¼ãã ã³ãã³ããå®è¡ãã ã³ãã³ãã®çµäºãå¾ ã¤ 1 ã«æ»ã ããããã®ã¾ã¾ Ruby ã§æ¸ãã¦ã¿ã¾ãã while true print '-> ' # ããã³ãã表示 cmd = gets or break # ã³ãã³ãå ¥å cmd.chomp! # æ«å°¾ã®æ¹è¡åé¤ pid = Process.fork do # åããã»ã¹çæ Process.exec [cmd, cmd] # ã³ãã³ãå®è¡ end Process.waitall # åããã»ã¹ã®çµäºå¾ ã¡ end Process
cronå®è¡æã®env: ruby: No such file or directoryã解決ãã¦ã¿ãæ稿è : Naoki æ稿æ¥: 2013-03-25 #!/usr/bin/env rubyã¨å®è¡ãã¡ã¤ã«ã«ããã¨ãæ®æ®µã¯Rubyãã¡ããã¨å®è¡ãããã®ã«cronã ã¨å®è¡ãããªãã®ã§èª¿ã¹ãã /usr/bin/env ã¯ã¦ã¼ã¶ã¼ã®ç°å¢è¨å®ãè¦ã¦rubyã®å ´æãæ¢ãã¦ãããã£ã½ãããªã®ã§ãããç°¡åã«è¨ãã¨cronã®å®è¡æã®ã·ã§ã«ã¹ã¯ãªããã«source /home/<ã¦ã¼ã¶ã¼å>/.bash_profileã£ã¦æ¸ãã¡ããã°è§£æ±ºãã¦ãã¾ã£ãã ãã ãããã¯ããæ¹ã¨ãã¦ãªãã綺éºãªãããªãæ°ããããä»ã®æ¹æ³ã調ã¹ããã
Working With Unix Processes ã¨ããæ¬ãèªãã ã Thin ã®ä½è ããã®ãææãã¼ã¸ã§ã³ãä½ãã¨ãåèã«ãããã¨ããã¡ãã»ã¼ã¸*1ãæ·»ãããã¦ããã®ã«æ¹ããã¦è²·ã£ããèè ã®ãµã¤ãã§ç´è²©ãã¦ãããã Kindle Store ãããè³¼å ¥ã§ããã ãã®æ¬ã¯ä¸è¨ã§ããã¨ã UNIX ç³» OS ã®ããã»ã¹ã«ã¤ãã¦ã®æ¬ã ãããã»ã¹ã¨ã¯ä½ããã¨ããå°å ¥é¨ããå§ã¾ã£ã¦ãããã»ã¹ ID ãããã»ã¹åãçµäºã³ã¼ãã¸ã¨è¨åãã fork(2) ãã½ã³ãããã»ã¹ãã·ã°ãã«ãããã¦ãã¼ã¢ã³ããã»ã¹ã®èª¬æãããã¾ã§æ¬ç·¨ä¸ã§èª¬æãã¦ããã UNIX ããã°ã©ãã³ã°ã«é¢ããé¡æ¸ã¯ 1000 ãã¼ã¸ãè¶ ãããã®ãå¤ããªãã§ããã®æ¬ã¯ããã 100 ãã¼ã¸ã»ã©ãããªã容æãèªãã*2ãããããã¼ã¸æ°ãå°ãªãã¶ãããã¾ãè¸ã¿è¾¼ãã å 容ã¨ã¯è¨ãããå ¨ä½çã«ããæµ ãå°è±¡ãåããããã§ã« UNIX, Li
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}