ããã«ã¡ã¯ãã¨ã ã¹ãªã¼ã§ã½ããã¦ã§ã¢ã¨ã³ã¸ãã¢ã¨ãã¦åãã¦ããå°æ¬ã§ãã
ç§ã¯åºç¤éçºãã¼ã ã¨ãããã¨ã ã¹ãªã¼ã®è¤æ°ã®ãµã¼ãã¹ã«ã¾ããã£ã¦ä½¿ãããã·ã¹ãã ãéçºã»éç¨ãããã¼ã ã«æå±ãã¦ãã¾ãã åºç¤éçºãã¼ã ãæ å½ããã·ã¹ãã ã®ï¼ã¤ã«ãä¼å¡åãã¡ã«ãã¬ã®é ä¿¡ã·ã¹ãã ãã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ããããã¾ã1ã
ã¨ã ã¹ãªã¼ã¯ã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ã§ï¼æ¥æ°åä¸éã®ã¡ã«ãã¬ãé ä¿¡ãã¦ãããæ©æ¢°å¦ç¿ã§ã¡ã«ãã¬ãæé©åããæ½ç2ãªã©ãã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ã®åå¨ãåæã«ãªã£ã¦ãã¾ãã
ãã®ããã«ã¨ã ã¹ãªã¼ã«ã¨ã£ã¦éè¦ãªã·ã¹ãã ãªã®ã§ãããã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ã¯æ°å¹´åã¾ã§éç¨ãç¹ã«ãããã¤ã«åé¡ãæ±ãã¦ãã¾ããããããã¤æã®ãã¹ã«ããé ä¿¡é害ãé »ç¹ã«çºçãæ°äººããããã¤ããã¨å¿ ãé害ãèµ·ããã¨ããç¶æ³ã ã£ãã®ã§ããã¾ãã1åãããã¤ããã®ã«30åãããããããã¤ä¸ã¯ã¡ã«ãã¬ã®é ä¿¡ãã§ãã¾ããã§ããã
ãæããããããã¤ãã®è¾ã
è¨ãã¾ã§ããªããé害ãçºçãã¦ããéã¯ã¡ã«ãã¬ãé ä¿¡ã§ãã¾ãããç¹ã«ãä»é ä¿¡ãããã¨ããéè¦ãªãã¥ã¼ã¹ç³»ã¡ã«ãã¬ã¯ãé害ã解æ¶ãã¦ããéãç´ãããã¨ãã§ããã大ããªæ©ä¼æ失ã«ç¹ããã¾ããã¾ããé害対å¿ã«æéãåãããã°ããã®ã¶ãéçºã«å²ããæéãå°ãªããªãã¾ãã
ããã ãã§ã¯ãªããã¨ã³ã¸ãã¢ã«ãããã¤ã«å¯¾ããææå¿ãå·ãè¾¼ã¾ãã¦ãã¾ããããããã¤ããããªãã®ã§ç®¡çç»é¢ã®è¡¨ç¤ºå´©ãã®ãããªç°¡åãªä¸å ·åä¿®æ£ãããããã£ãããè¤æ°ã®å¤æ´ãä¸ã¤ã«ã¾ã¨ãã¦ãªãªã¼ã¹ããããã¦ãã¾ããã
ããããGithubã¯1æ¥ã«175åãããã¤ãããAmazonã¯1æéã«1079åãããã¤ãã ã£ã¦è©±ãªã®ã«3ãã¨ã ã¹ãªã¼ã§ã¯1å30åãããããªãã¦ãããããï¼ï¼ãã¨æãã¾ããããããã¤ã¯ããèªä½ã¯ä¾¡å¤ãç£ã¾ãªãä½æ¥ã§ãããããé害ã®æããããå±éºãªä½æ¥ãã§ã¯ãªãã誰ã§ãã§ããç°¡åãªã«ã¼ãã³ã¯ã¼ã¯ãã§ããã¹ãã§ãã
åºç¤éçºãã¼ã ã§ã¯ãã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥æ¬ä½ã®éçºã®ããããããããã¤ã®æ¹åãè¡ãªã£ã¦ããã¾ããã
ãããã¤æé æ¸ã®ä½æ
ã¾ããã¨ãããæ°äººããããã¤ããã¨å¿ ãé害ãèµ·ããã¨ããç¶æ³ãä½ã¨ããããã¨ã«ãã¾ãããããããããªããããã¤ä½æ¥ä¸ã«ãã¹ããããã¨ããã¨ãæé æ¸ããããªç°¡åãªã¡ã¢ãããã ãã ã£ãããã§ãï¼
ãµã¼ãã¼ã«SSHãã cd /app/mail_concierge/mail_concierge/ git pull origin master unicornãåèµ·å ãã¹ãé ä¿¡ãã
ä¾ãã°åã«ããã¹ãé ä¿¡ãããã¨æ¸ããã¦ãæé æ¸ã¨ãã¦ã¯å½¹ç«ã¡ã¾ãããé ä¿¡ã«ã¯è¤æ°ã®ãªãã·ã§ã³ããããããã©ã³ã¯ã¨ãããæ°äººã«ã¯ãã©ããªè¨å®ã§ãã¹ãé ä¿¡ããã°ãããåãããªãããã§ãã
æ°äººã§ãééãããã¨ãç¡ããããå ¨ã¦ã®è¨å®é ç®ãæå®ããã³ããããã ãã§ãããã¤ã§ãããããªæé æ¸ã«æ¸ãæãã¾ãããããã¹ãé ä¿¡ããªã以ä¸ã®ãããªæãã§ãï¼
1. mail-contents.xlsããã¦ã³ãã¼ããã 2. ãäºåçæã³ã³ãã³ããç»é¢ãã mail-contents.xls ãã¢ãããã¼ããã - ãã®æãæ¥ä»ãã¯ä»æ¥ãæå®ãã 3. ãé ä¿¡ç»é²ãç»é¢ãã以ä¸ã®å 容ãå ¥åãããé ä¿¡ç»é²ããã - ãµã¼ãã¹: ãé ä¿¡ãã¹ãã - ã¡ã«ãã¬: ãé ä¿¡ãã¹ãï¼HTMLã - ã¡ã¼ã«ãã³ãã¬ã¼ã:ããããã¤æ試é¨é ä¿¡1ãããããã¤æ試é¨é ä¿¡2ã - é ä¿¡ãªã¹ã: ãé ä¿¡ãªã¹ãã®ç¨®é¡ãé¸æ - é ä¿¡ãã¹ãç¨ãªã¹ãã - é ä¿¡å: ããããã¤æ試é¨é ä¿¡/YYYYMMDDã - ãã¬é ä¿¡ç: ã50%ã - åè 決å®ãã¸ãã¯: ãéå°åã®ã¯ãªãã¯çã - ãã¬é ä¿¡éå§æ¥æ: ç¾å¨æå»ãã5åå¾ - æ¬é ä¿¡éå§æ¥æ: ç¾å¨æå»ãã10åå¾ - é 信対象ã©ã³ã¯: ãé 信対象ã©ã³ã¯ãæå®ãã - NOã
ããã§ãæ¬çªç°å¢ã¸ã®ãããã¤ã¯ï¼ä¸å¿ï¼èª°ã§ãå®å ¨ã«ã§ããããã«ãªãã¾ããã
ã¹ãã¼ã¸ã³ã°ç°å¢ã®è¿½å
次ã«ããããã¤ä½æ¥ã®èªååããããã£ãã®ã§ããããããã¤ç¨ã®ã¹ã¯ãªããããã¹ãã§ããªãã¨ããåé¡ãããã¾ããã
æ¬çªç°å¢ã®ä»ã«éçºç°å¢ããã£ãã®ã§ãããããã¾ã§éçºç¨ã§ãããããæ¬çªã¨ã®å·®ç°ãããã¾ããã ä¾ãã°ãæ¬çªã¯ãµã¼ãã¼ï¼å°æ§æãªã®ã«éçºç°å¢ã¯ï¼å°ã§ããï¼ãã¤ã¦ã¯ãµã¼ãã¼ã®ã³ã¹ããé«ãã£ããããæ¢ããå¾ãªãé¨åãããã¾ããï¼ã
ã¨ã¤ã¤ãï¼ã¨ãæ¬çªç°å¢ã§å®è¡ãããã¨ãã§ãã¾ããããããããã§é害ãèµ·ãã¦ãã¾ã£ã¦ã¯æ¬æ«è»¢åã§ãã
çµå±ãè¤æ°å°æ§æã®ã¹ãã¼ã¸ã³ã°ç°å¢ãç¨æãã¾ããã
å®éã«æ¬çªåæ§ã®ã¹ãã¼ã¸ã³ã°ç°å¢ãä½ã£ã¦ã¿ãã¨ãéçºã®éã«ãæ¬çªåçã®ç°å¢ã®æ¹ã便å©ã ã¨åããã¾ããã ä»ã§ã¯ãã¹ãã¼ã¸ã³ã°ç°å¢ãï¼ã¤ã«å¢ããããã¤ã¦ã®éçºç°å¢ã¯å»æ¢ãã¦ãã¾ãã
ãããã¤ã®èªåå
æé æ¸ã®å 容ãå®è¡ããã·ã§ã«ã¹ã¯ãªãããä½ãã¾ãã4ã
ã³ãã³ããï¼åå®è¡ããã ãã§ãåãµã¼ãã¼ã«SSHãææ°ã³ã¼ãã®ãã§ãã¯ã¢ã¦ããã¤ã³ã¹ãã¼ã«ããµã¼ãã¼åèµ·åãç°¡åãªåä½æ¤è¨¼ãã¾ã§ãå®äºãã¾ãã
ããã«ããå¿ççå¹æã¯è«å¤§ã§ãããä»ã¾ã§ã¯ããããããï¼ãã¨æ°åããå ¥ãæé æ¸ãè¦ãªããæ éã«ãã¦ããä½æ¥ãããããããé¢åããã㪠ï¾ï¾ï¾ï¾ï¾ï¾ ãã§åºæ¥ãããã«ãªã£ããã§ãããã
ãããã¤ã®æ¹è¯
æé æ¸ãã¹ã¯ãªãããä½ãç®ã«è¦ããå½¢ã«ãããã¨ã§ããããã¤æé ã«ã¤ãã¦è°è«ã§ããããã«ãªãã¾ããï¼ä»ã¾ã§ã¯ãè°è«ãããã«ãã§ããªãã£ãï¼ã
æéç縮
ã¡ã«ãã¬ãé ä¿¡ã§ããªãæéãæ¸ãããããã¹ã¯ãªãããæ¹è¯ãã¦ããã¾ããããããã¤ã®å¤§é¨åã¯ãGitã¬ãã¸ããªã® clone ãRubyã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«ã ã£ãããã以ä¸ã®ãããªæ¹åããã¾ããã
- git ã®ãã©ã¼ãªã³ã°ã¬ãã¸ããªãå©ç¨ãã
- Ruby ã®ã©ã¤ãã©ãªããã£ãã·ã¥ãã
- ã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«ã¯ããã¯ã°ã©ã³ãã§è¡ããã¤ã³ã¹ãã¼ã«ãçµãã£ã¦ãããæ¬ä½ã®åãæ¿ãããã
ããã«ããããããã¤æéï¼= ã¡ã«ãã¬ãé ä¿¡ã§ããªãæéï¼ãçããããã¨ãã§ãã¾ããã
DBã¸ã®ãã¼ã¿æå ¥ã§ psql ãããã
èªååã«ããRubyã®ã³ã¼ãã®ãããã¤ã¯å®å ¨ã»ç°¡åã«ãªãã¾ãããããã¾ã«è¡ãä½æ¥ã®ä¸ã«ã¯å±éºãªãã®ãæ®ã£ã¦ãã¾ããã ä¸ã¤ã¯ãã¡ã«ãã¬ã追å ãããããæãªã©ã«DBã®å 容ãå¤æ´ããä½æ¥ã§ãããã¤ã¦ã¯ãããã
ããµã¼ãã¼ã«SSH â psql ãéãâ ã¹ããããããSQLãã³ãããã¦å®è¡ã
ã¨ããåå§çãªæ¹æ³ã§è¡ãªã£ã¦ãã¾ããããã®ããã§äºæ ãå¤ããå½æãDBå¤æ´ã¯æ¬è³ªçã«å±éºãªä½æ¥ãªãã ãã¨è¨ããã¦ãã¾ããã ããããDBå¤æ´ããããããä½æ¥ããªã®ã§ããããã§ããããã«ããã¹ãã§ãããã
ã¾ããseed_fu ãå°å ¥ãã¾ãããseed_fu ã¯Railsæ¨æºã® rails db:seed ã®å¼·åçã§ããåªçæ§ããããç¹°ãè¿ãå®è¡ãã¦ããã¼ã¿ãå£ãã¾ããããããããã¹ã¿ã¼ãã¼ã¿ã®å¤æ´ã¯ãseed_fu ã§ç®¡çãã¾ãã
ã¾ããseed_fuã使ããªãå ´åãpsql ã§ã¯ãªããSQLãå®è¡ããrake ã¿ã¹ã¯ããããã¤ãã¨ã«ä½ãããã«ãã¾ããã
namespace :manual_rollout do desc 'ãã¼ã¸ãªã¯ã¨ã¹ã 793' task mr793: :environment do raise 'æ¬çªç°å¢ã§ã®ã¿å®è¡å¯è½ã§ã' if !Rails.env.production? helper = RolloutHelper.new('mr793') # ã¡ã«ãã¬ã®è¿½å sql = Rails.root.join('db/sql/20180523_add_mail_magazine_patient_support_by_mail_address.sql').read helper.execute_sql(sql) end end
seed-fu ã rake ã使ãããã«ãªã£ããã¨ã§ããããã¤æã«ã¯ã³ãã³ããï¼ã¤å®è¡ããã ãã§æ¸ã¿ããã¹ã¯èµ·ããªããªãã¾ããã
ã¾ããä»ã¾ã§ãããã¤æã«å®è¡ããSQLã¯ãGitã§ç®¡çãã¦ãã¾ããã§ããï¼ã©ãã1åãã使ããªãã®ã§ï¼ã ããããseed-fu ã®è¨å®ãã¡ã¤ã«ãrakeã¿ã¹ã¯ã¯ãRubyã®ã³ã¼ãã¨ä¸ç·ã«Gitã§ç®¡çããããã«ããã®ã§ã
- ã³ã¼ãã¬ãã¥ã¼ãããã
- éå»ã®å±¥æ´ãããã®ã¼ãã
- git checkout ããã ãã§ããµã¼ãã¼ä¸ã«ã³ãã¼ã§ãã
ã¨ãããRubyã¨åãã¡ãªãããå¾ãããããã«ãªãã¾ããã
Rubyã®ã³ã¼ãã¨åããããã®å®å ¨ã»ä¾¿å©ã«DBå¤æ´ãåºæ¥ãããã«ãªãã¾ããã
crontabãç·¨éããã®ãããã
ããä¸ã¤ããã¾ã«è¡ãå±éºãªä½æ¥ããããã¾ãããcrontab ã®å¤æ´ã§ãã
ã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ã®ããã¯ã°ã©ã¦ã³ãã¸ã§ã㯠cron ã§ç®¡çãã¦ãã¾ã5ã ã¸ã§ãã®å®è¡é »åº¦ãå¤ãããããã¨ãã¯ãcrontab ãå¤æ´ããªããã°ãªãã¾ããããããããããè¾ãã£ãã
# crontab ãå¤æ´ããã¨ã 1. crontab -e ã§ã¨ãã£ã¿ãéã 2. crontab ã®æå®ã®é¨åãåé¤ãã 3. config/mail-concierge-web1.crontab ã®å 容ãè²¼ãä»ãã
ã®ãããªãç´ æ´ãªæä½æ¥ã§ãã³ãããã¹ã§ææ³ã¨ã©ã¼ã«ãªããã¸ã§ããå®è¡ãããªãã£ãããééãã¦ã¸ã§ããæ¶ãã¦ãã¾ã£ããã¨ãã£ãäºæ ãèµ·ãã¾ããã
ããã§ãcrontab ãwheneverã§ç®¡çããããã«ãã¾ããã whenever 㯠crontab ãRubyã®DSLã§æ¸ããã³ãã³ã㧠crontab ã®å¿ è¦ãªé¨åã ãæ¸ãæãããã¨ãã§ãã¾ãã
whenever ã«ãã crontab ã®æ´æ°ã¯ç°¡åã«ãªãã¾ãããããã©ãããããããã¤ã¹ã¯ãªããä¸ã§ whenever ãå®è¡ããããã«ãã¦ã ãcrontab ã®æ´æ°ãã¨ããä½æ¥èªä½ãç¡ããªãã¾ããã
ãããã¤ãæããªããªã£ãï¼ï¼
ç¾å¨ã§ã¯ä½æ¥ãã¹ã«ããé害ã¯ã»ã¼ç¡ããªãã¾ãããã¾ãããããã¤ã¯ï¼åç¨åº¦ã§å®äºãããã®éãã¡ã«ãã¬ãæ¢ããå¿ è¦ãããã¾ããï¼GithubãAmazonã»ã©ã®é »åº¦ã§ã¯ãããã¤ãã¦ãã¾ãããï¼ãã¾ãããããã¤ãå®å ¨ã«ãªã£ããã¨ã§ãå¿ç½®ãç¡ãéçºã«æéãå²ããããã«ãªããUIæ¹åãé ä¿¡æ§è½ã®åä¸ãªã©ã®æ©è½è¿½å ãã§ããããã«ãªãã¾ããã
ã¾ã¨ã
ã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ã§ã¯ã
- ãããã¤æé æ¸ãä½ã£ã
- ã¹ãã¼ã¸ã³ã°ç°å¢ãä½ã£ã¦ããããã¤èªååããã¹ãã§ããããã«ãã
- ã·ã§ã«ã¹ã¯ãªããã§ãããã¤ãèªååãã
- å種ãã¼ã«ã§DBãcrontabã®å¤æ´ãç°¡åã»å®å ¨ã«ã§ããããã«ãã
- ãã®çµæãéçºã«æéãå²ããããã«ãªã£ãï¼ï¼
ã¨ã³ã¸ãã¢ãåéãã¦ãã¾ãï¼
åºç¤éçºãã¼ã ã§ã¯ãã¡ã¼ã«ã³ã³ã·ã§ã«ã¸ã¥ä»¥å¤ã«ãã ä¼å¡èªè¨¼åºç¤ãªã©ã®ã¨ã ã¹ãªã¼å ¨ä½ãæ¯ããæ§ã ãªã·ã¹ãã ãéçºã»éç¨ãã¦ãã¾ãã
ã¾ããäºæ¥ããä¸æ©å¼ããç«ã¡ä½ç½®ã«ããã®ã§ãæ°æè¡å°å ¥ãéçºããã¼ã®æ¹åãªã©ããªã¼ããã¦ãããã¨æã£ã¦ãã¾ãã ï¼æè¿ã¯Dockerãå°å ¥ããJenkinsããGitlab-CIã¸ã®ç§»è¡ãªã©ãè¡ãã¾ãããï¼
ä¸ç·ã«åã仲éã絶è³åéä¸ã§ãããæ°è»½ã«ãåãåãããã ããã
-
Ruby on Railsã§ä½ããã¦ãããDBã社å ã·ã¹ãã ã¨ã®é£æºãéå°çãã¯ãªãã¯çã®è¨æ¸¬ãA/Bãã¹ãããªã©åç¨ãµã¼ãã¹ã¨éè²ç¡ãã»ã©é«æ©è½ãªã¢ããªã±ã¼ã·ã§ã³ãªã®ã§ãããããã«ã¤ãã¦ã¯å¥ã®æ©ä¼ã«ç´¹ä»ãã¾ãã↩
-
ãã®ãããã¯ãå¥ã®è¨äºã§ç´¹ä»ãããã¨æãã¾ãã↩
-
2012å¹´æç¹ã®æ°åã®è©±ã§ããã¢ãã¾ã³ã¯ç¾å¨0.5ç§ã«1åã ããã§ããã↩
-
Capistrano ã Fabric ã使ã£ã¦ãããã£ãã®ã§ãããå½æã¯ãã¼ã å ã§ä½¿ã£ãçµé¨ãããã¾ããã§ãããããã§æ©ãããã¯ãã¨ã£ã¨ã¨èªååãã¦æ¥½ããããã»ãããã¤ãéãå®å ¨ã«ãããã£ããããã·ã§ã«ã¹ã¯ãªããã§æ¸ãã¦ãã¾ãã¾ããã↩
-
ã¯ããcronã¯ã¤ã«ãã¦ãªãã¨æãã¾ããä»ããè¨è¨ãããªã cron ã«ã¯ãã¾ããããå°æ¥ã¯å¥ã®ã¹ã±ã¸ã¥ã¼ã©ã«å¤ããããããã¾ããããã¨ã«ããä»ã¯ cron ãªã®ã§ãã↩