Mavericksã«Supervisorãã¤ã³ã¹ãã¼ã«ãã¦ã¿ã
Macä¸ã§daemontoolsã¿ãããªãã¨ãããå欲ããã£ãã®ã§ã使ã£ããã¨ãªããã©ä»¥åããæ°ã«ãªã£ã¦ããSupervisorã試ãã¦ã¿ã¾ãããSupervisorã¯Python製ã®ããã»ã¹ç®¡çãã¼ã«ã§ããçµè«ããè¨ãã¨root権éãå¿ è¦ãªããconfãæ¸ããããã®ã§ãªã¹ã¹ã¡ã§ãã
Pythonã¤ã³ã¹ãã¼ã«
homebrewããã¤ã³ã¹ãã¼ã«ãã¾ãããã
$ brew install python
pip
Pythonã¤ã³ã¹ãã¼ã«å¾ã®ç»é¢ã«è¡¨ç¤ºãããããã«setuptoolsã¨pipãupgradeãã¾ãã (åèï¼https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python)
$ pip install --upgrade setuptools $ pip install --upgrade pip
Supervisorã¤ã³ã¹ãã¼ã«
pipã§ä¸æã§ãã公式ドキュメントã«ããã¨pipã®ãã¼ã¸ã§ã³ã1.4以ä¸ã¯--preãªãã·ã§ã³ã¤ãã¦ããã¨è¨è¿°ãããã®ã§è¿½è¨ãã¦ãã¾ãã
$ pip install supervisor --pre
supervisord.conf
è¨å®ãã¡ã¤ã«ãç¨æãã¾ãã
$ mkdir -p /usr/local/share/supervisor/conf.d $ cd /usr/local/share/supervisor $ echo_supervisord_conf > supervisord.conf
ä½æããè¨å®ãã¡ã¤ã«ã¯ã»ã¼ããã©ã«ãã§ããã®ã§ããä¸ç®æã ãä¿®æ£ãã¾ãã supervisord.conf138è¡ç®ãããã§ãã
[include] - files = /etc/supervisord.d/*.ini + files = /usr/local/share/supervisor/conf.d/*.conf
管çä¸ã«ç½®ãããããã°ã©ã ã®è¨å®ãã¡ã¤ã«ã®ä½æ
Supervisorã§ç®¡çãããããã°ã©ã ã®è¨å®ãä½æãã¾ãã hubotã§ãµã³ãã«æ¸ãã¦ã¿ã¾ãã
$ touch /usr/local/share/supervisor/conf.d/hubot.conf
ä½æããhubot.confã«ä¸è¨ã®è¨å®ãè¨è¿°ãã¾ãã hubotã®æ³¨æç¹ã¨ãã¦npmãåãããã«PATHãéãã¦ããå¿ è¦ãããã¾ããã ç»é²ããããã°ã©ã ã«å¿ãã¦PATHã®è¦ç´ãããã¦ãã ããã
[program:hubot] command=/Users/mitz/work/myhubot/bin/hubot -a irc --name hubot directory=/Users/mitz/work/myhubot user=mitz numprocs=1 stdout_logfile=/tmp/hubot_out.log stdout_logfile_maxbytes=10MB stdout_logfile_backups=3 stderr_logfile=/tmp/hubot_err.log stderr_logfile_maxbytes=10MB stderr_logfile_backups=3 autostart=false autorestart=true environment=PATH="/usr/local/bin:$PATH",HOME="/Users/mitz/work/myhubot", \ USER="mitz",HUBOT_IRC_SERVER="irc.example.local",HUBOT_IRC_ROOMS="#mitz", \ HUBOT_IRC_NICK="hubot",HUBOT_IRC_UNFLOOD="true"
èµ·å確èª
Supervisorãåããã©ãã試ãã¦ã¿ã¾ãããã
$ supervisord -c supervisord.conf $ supervisorctl start hubot
supervisordãlaunchdã«ç»é²
supervisordããã·ã³èµ·åæã«ããã»ã¹ãç«ã¡ä¸ããããã«launchdã«ç»é²ãã¾ãã
$ touch ~/Library/LaunchAgents/com.agendaless.supervisord.plist
com.agendaless.supervisord.plist ã«ä¸è¨ãè¨è¿°ãã¦ãã ããã
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict> <key>Label</key> <string>com.agendaless.supervisord</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/supervisord</string> <string>-n</string> <string>-c</string> <string>/usr/local/share/supervisor/supervisord.conf</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
ããã§launchctlã§supervisordãåãããã«ãªãã¾ããã
$ launchctl load ~/Library/LaunchAgents/com.agendaless.supervisord.plist
ããã§ã¯ããSupervisorã©ã¤ãããéããã ããï¼