Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Webアプリのデプロイ今昔物語

 Webアプリのデプロイ今昔物語

PHP Conference Japan 2014
https://joind.in/12041

91282e22a7b16331c49c8d47eafcac14?s=128

Kenji Akiyama

October 11, 2014
Tweet

Transcript

  1. 8FCΞϓϦͷ
 σϓϩΠࠓੲ෺ޠ 1)1$POGFSFODF+BQBOc IUUQTKPJOEJO

  2. ळࢁݦ࣏ ,FOKJ"LJZBNB גࣜձࣾϋ΢ςϨϏδϣϯ ΤϯδχΞ ! !BSUJGBDUTBVDF !BSUJGBDUTBVDF  ,FOKJ"LJZBNB !

    ؾ͕͚ͭ͹ࡀ
  3. ֎ࢿब׆υοτίϜ w ৽ଔ޲͚ٻਓϝσΟΞ w ೥ϦϦʔε w ౦େʗܚԠେͷब׆ੜͷ൒ ਺͕ձһొ࿥͍ͯ͠Δ w 8PSE1SFTTͱ$BLF1)1Ͱ

    Ͱ͖͍ͯΔ
  4. εΩϧηοτ

  5. ࠷ۙ͸

  6. None
  7. None
  8. ࢓ࣄ΋ϓϥΠϕʔτ΋ ஍ຯͳ໾ׂ͕େ޷͖

  9. ҎલͷΩϟϦΞ ཧֶ̋ݚڀॴʹ೥΄Ͳ ! w όΠΦΠϯϑΥϚςΟΫε w ੜ෺σʔλͷղੳ w σʔλϕʔεߏங w

    8FCΞϓϦ։ൃ
  10. ࠓճͷझࢫ ‣ ओʹதখن໛8FCΞϓϦΛ։ൃ͖ͯͨ͠ ਓͷࢹ఺Ͱɺ8FCΞϓϦͷσϓϩΠʹ· ͭΘΔྺ࢙ΛৼΓฦΓͳ͕Βɺͳͥࠓɺ͜ ͷΑ͏ͳܗʹͳ͍ͬͯΔͷ͔ʁ͜Ε͔ΒͲ ͷΑ͏ʹͳΔͷ͔ʁΛߟ͑Δɻ ‣ ࣗ୐αʔόʔ೿΍σʔληϯλʔར༻೿ͳ Ͳ͸·ͨผͷྺ࢙ΛาΜͰ͍·͢ͷͰɺࠓ

    ճͷࢹ఺͔Β͸ζϨͯ͘Δͱࢥ͍·͢ɻ
  11. ஫ҙ ‣ ͓͓Αͦͷ࣌୅ͷྲྀΕΛ͔ͭΉ͜ͱ͕໨త Ͱ͋Γɺݫີͳ΋ͷͰ͸͋Γ·ͤΜɻ ‣ ࡉ͔͍͜ͱ͸ؾʹ͠ͳ͍ͰɺβΝʔͬͱฉ ͍͍ͯͩ͘͞ɻ

  12. ର৅ͱ͍ͯ͠Δਓ ‣ 8FCΞϓϦ։ൃͷॳ৺ऀ ‣ σϓϩΠπʔϧΛ࢖͍࢝Ίͨ͹͔Γͷਓ ‣ σϓϩΠπʔϧΛ࢖͍ͬͯΔ͚Ͳɺ࢖͍࢝ ΊΔલͷ͜ͱΛ஌Βͳ͍ਓ

  13. –Wikipedia ιϑτ΢ΣΞσϓϩΠϝϯτʢӳ4PGUXBSF EFQMPZNFOUʣͱ͸ɺιϑτ΢ΣΞγεςϜΛར ༻Մೳʹ͢Δ׆ಈશൠΛࢦ͢༻ޠͰ͋Δɻσϓϩ Πϝϯτʢ%FQMPZNFOUʣͱ͸ʮల։ɺ഑උɺ഑ ஔʯͳͲͷҙɻ

  14. 8FCΞϓϦͷσϓϩΠͷྺ࢙ ‣ Ϩϯαό࣌୅ ‣ 714࣌୅ ‣ 1BB4࣌୅ ‣ *BB4࣌୅

  15. Ϩϯαό ‣ Ϩϯλϧαʔόʔͷུ ‣ ϗεςΟϯάαʔόʔ·ͨ͸ڞ༻αʔόʔͱ΋ ݺ͹ΕΔ ‣ ෳ਺ͷར༻ऀʹσΟεΫεϖʔεΛି͠ग़͢αʔ Ϗε ‣

    Ϧιʔεʢ$16.FNͳͲʣ͸ར༻ऀͰڞ༗ ͢Δ ‣ $(*44*͕ಈ͔ͤΔʢ΋ͷ΋͋Δʣ
  16. Ϩϯαό࣌୅ ‣ ೥୆ޙ൒͔Β೥ॳ಄͔ʁ ‣ Ϩϯλϧαʔόʔ͘Β͍͔͠બ୒ࢶ͕ແ͔ͬ ͨ࣌୅ʢٕज़తʹ΋ۚમతʹ΋ʣ ‣ தখن໛ͷαʔϏεʹ͸઎༗αʔόʔͳΜ ͯख͕ग़ͳ͍ɻ

  17. ͜ͷ࣌୅ ‣ 1FSMʢ೥ʣ ‣ $(*"QQMJDBUJPOʢ೥ʣ ‣ 1)1ʢ೥ʣ ‣ 8JOEPXTʢ೥ʣ ‣

    4VCWFSTJPOʢ೥ʣ
  18. Ϩϯαόʹ͓͚ΔσϓϩΠ ‣ ओྲྀ͸8JOEPXTΫϥΠΞϯτ͔Βͷ'51 Ξοϓϩʔυ ‣ αʔόʔઃఆʹख͕ग़ͤͳ͍ͨΊɺ௨৴ख ஈͷબ୒ࢶ͕'51Ҏ֎ʹແ͍ɻ

  19. Ϩϯαόʹ͓͚ΔσϓϩΠͷ໰୊఺ ‣ '51ͳͷͰηΩϡϦςΟ͕؁͍ ‣ ҉߸Խ͞Ε͍ͯͳ͍ύεϫʔυ͕ωοτ ϫʔΫʹྲྀΕΔɻ ‣ ڞ௨ΞΧ΢ϯτͰίϯςϯπ؅ཧ ‣ ΞΧ΢ϯτ͕Θ͔Ε͹ԿͰ΋Ͱ͖Δɻ

  20. ΞϓϦͷංେԽ ‣ ංେԽ͢Δ8FCΞϓϦͷॲཧ଎౓Λվળ ͠Α͏ͱ͍͏ࢼΈ͕ਐΉɻ ‣ NPE@QFSMʢ೥ʣ ‣ 'BTU$(*ʢ೥ʣ

  21. ΞϓϦͷංେԽ ‣ ංେԽ͢Δ8FCΞϓϦͷॲཧ଎౓Λվળ ͠Α͏ͱ͍͏ࢼΈ͕ਐΉɻ ‣ NPE@QFSMʢ೥ʣ ‣ 'BTU$(*ʢ೥ʣ ϨϯαόͰ͸͜ΕΒͷٕज़Λར༻Ͱ͖ͳ͍

  22. 714࣌୅ ‣ 7JSUVBM1SJWBUF4FSWFS ‣ ෺ཧίϯϐϡʔλʔ্ͰԾ૝తʹίϯ ϐϡʔλʔΛෳ਺ىಈ͢Δٕज़Λ༻͍ͯ ࡞ΒΕͨԾ૝తͳίϯϐϡʔλʔ ‣ 7.8BSF 

    'SFF#4%KBJM  7JSUVP[[P  9FO  8JOEPXT4FSWFS   4PMBSJT$POUBJOFS  ,7. 
  23. ͜ͷ࣌୅ ‣ ೥ॳ಄͔Β೥୆લ൒ ‣ σεΫτοϓ-JOVY͕࢖͑Δ΋ͷʹͳͬͯ ͖ͨɻ ‣ 1FSMʢ೥ʣ ‣ 1)1ʢ೥ʣ

    ‣ 3VCZPO3BJMTॳެ։ʢ೥ʣ
  24. 714ͷϝϦοτ ‣ Ϧιʔεʢ$16.FN)%%ͳͲʣҎ֎͸ ࣗ༝ʹͰ͖Δɻ ‣ ϛυϧ΢ΣΞ΍ϓϩάϥϛϯάݴޠͳͲ ‣ ΞΧ΢ϯτ؅ཧ ‣ ௨৴ํ๏΋44)Λ࢖͑ΔΑ͏ʹͳͬͨ

    ‣ 0QFO44)ͷීٴ͸೥͔Β
  25. 714ʹ͓͚ΔσϓϩΠ ‣ -JOVYΫϥΠΞϯτ͔ΒͷSTZOD ‣ ίϚϯυϥΠϯ͔Β44)Λ௨ͯ͠ΞΫη ε͢Δ ‣ ϦϞʔταʔόʔͱϑΝΠϧಉظΛͱΔ

  26. ͢΂͕ͯ͏·͍ͬͨ͘ ΋͏೰ΈͳΜͯແ͍

  27. ͦΜͳΘ͚ͳ͍ ͢΂͕ͯ͏·͍ͬͨ͘ ΋͏೰ΈͳΜͯແ͍

  28. ΞϓϦͷߏ੒ͷෳࡶԽ ‣ ϓϩηεͷӬଓԽ ‣ ੩తϑΝΠϧ͚ͩ͸ผαʔόʔ ‣ +BWBTDSJQUͷ೉ಡԽʗ࠷খԽ ‣ Ωϟογϡͷอ࣋

  29. ෳࡶԽ΁ͷରॲ ‣ εΫϦϓτΛॻ͍ͨ͆ ‣ ൿ఻ͷλϨ͕׬੒

  30. σϓϩΠπʔϧͷ஀ੜ ‣ $BQJTUSBOP ‣ ೥ʹ4XJUDI5PXFS͔Βվ໊ ‣ ։ൃ౰ॳ͸4IFMM4DSJQU ‣ 3VCZͰॻ͖௚͞ΕΔ ‣

    ݱࡏͷόʔδϣϯ͸
  31. $BQJTUSBOP ‣ ෳ਺ͷαʔόʔ্ͰεΫϦϓτΛ࣮ߦ͢Δ ͨΊͷΦʔϓϯιʔεͷπʔϧ ‣ ͭҎ্ͷ8FCαʔό্ͷΞϓϦέʔγϣ ϯΛ৽͍͠όʔδϣϯʹ͢Δ࡞ۀΛࣗಈԽ

  32. $BQJTUSBOPEFQMPZ Current "QQ4FSWFS (JU4FSWFS σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  33. $BQJTUSBOPEFQMPZ Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  34. $BQJTUSBOPEFQMPZ Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  35. $BQJTUSBOPEFQMPZ Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  36. $BQJTUSBOPEFQMPZ New Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  37. $BQJTUSBOPEFQMPZ New Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  38. $BQJTUSBOPEFQMPZ New Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  39. $BQJTUSBOPEFQMPZ New Current "QQ4FSWFS (JU4FSWFS $ cap production deploy σϑΥϧτͰ༻ҙ͞Ε͍ͯΔEFQMPZλεΫ

  40. EFQMPZUBTL ‣ EFQMPZTUBSUJOH ‣ EFQMPZDIFDL ‣ HJUDIFDL ‣ EFQMPZDIFDLEJSFDUPSJFT ‣

    EFQMPZDIFDLMJOLFE@EJST ‣ EFQMPZDIFDLNBLF@MJOLFE@EJST ‣ EFQMPZDIFDLMJOLFE@pMFT ‣ EFQMPZTUBSUFE ‣ EFQMPZVQEBUJOH ‣ HJUDSFBUF@SFMFBTF ‣ EFQMPZTZNMJOLTIBSFE ‣ EFQMPZTZNMJOLMJOLFE@pMFT ‣ EFQMPZTZNMJOLMJOLFE@EJST ‣ EFQMPZVQEBUFE ‣ EFQMPZQVCMJTIJOH ‣ EFQMPZTZNMJOLSFMFBTF ‣ EFQMPZQVCMJTIFE ‣ EFQMPZpOJTIJOH ‣ EFQMPZDMFBOVQ ‣ EFQMPZpOJTIFE $BQJTUSBOPͷσϓϩΠϑϨʔϜϫʔΫͷ࢖͍ํ աڈܗͰه͞Ε͍ͯΔλεΫ͸ۭͷλεΫ ͳͷͰ͜ΕΒΛඞཁʹԠ্ͯ͡ॻ͖͢Δ
  41. جຊํ਑ ‣ σϑΥϧτʹدͤͯΈΔ

  42. ͔ͭͯͷσϓϩΠखॱ  (JUͷ։ൃϒϥϯν͔ΒANBTUFSAϒϥϯν΁Ϛʔδ͢Δ  ࡞ۀͷ։࢝Λ4MBDLͰશһʹ௨஌͢Δ  લճͷσϓϩΠ͔Βมߋͷ͋ͬͨϑΝΠϧ͚ͩΛαʔόʔʹίϐʔ͢Δ  ݱߦόʔδϣϯͷσΟϨΫτϦΛ৽ͨͳόʔδϣϯ໊Λ෇͚ͯίϐʔ͢ Δ

     αʔόʔʹίϐʔͨ͠ϑΝΠϧͰ৽όʔδϣϯσΟϨΫτϦͷϑΝΠϧ Λ্ॻ͖͢Δ  ݱߦόʔδϣϯͷσΟϨΫτϦΛࢦ͢4ZNMJOLΛɺ৽όʔδϣϯσΟϨ ΫτϦΛࢦ͢Α͏ʹ࡞੒͠௚͢  $BDIFϑΝΠϧΛ࡟আ͢Δ  QIQGQNΛ࠶ىಈ͢Δ  ࡞ۀͷऴྃΛ4MBDLͰશһʹ௨஌͢Δ
  43. ͔ͭͯͷσϓϩΠखॱ # local ! $ git checkout master $ git

    pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart
  44. ࣗಈԽͷԸܙ # local ! $ git checkout master $ git

    pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart
  45. ࣗಈԽͷԸܙ # local ! $ git checkout master $ git

    pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart # local ! $ cap production deploy
  46. ࣗಈԽͷԸܙ # local ! $ git checkout master $ git

    pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart # local ! $ cap production deploy UBLFOCZXJFENBJFS
  47. ࣗಈԽͷԸܙ ࣌ؒ UBLFOCZIJQQPOPUJ[FE

  48. ࣗಈԽͷԸܙ ࣌ؒ UBLFOCZIJQQPOPUJ[FE ෼ UBLFOCZQIPUPOT

  49. ࣗಈԽͷԸܙ ࣌ؒ UBLFOCZIJQQPOPUJ[FE ෼ UBLFOCZQIPUPOT ഒ

  50. ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|

    ["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end
  51. ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|

    ["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ΁ ϦϯΫΛுΔ
  52. ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|

    ["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ΁ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ
  53. ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|

    ["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ΁ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ σʔλϕʔεϚΠάϨʔ γϣϯΛ࣮ߦ͢Δ
  54. ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|

    ["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ΁ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ DPNQBTTͰTBTTϑΝΠϧ ΛίϯύΠϧ͢Δ σʔλϕʔεϚΠάϨʔ γϣϯΛ࣮ߦ͢Δ
  55. ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|

    ["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ΁ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ DPNQBTTͰTBTTϑΝΠϧ ΛίϯύΠϧ͢Δ σʔλϕʔεϚΠάϨʔ γϣϯΛ࣮ߦ͢Δ ΞϓϦέʔγϣϯಛҟతͳλεΫΛ௥ ه͍ͯ͘͠
  56. ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,

    :service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end
  57. ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,

    :service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ
  58. ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,

    :service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ QVCMJTIJOHλεΫͷޙ ʹ࣮ߦͯ͠Ͷὑ
  59. ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,

    :service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ QVCMJTIJOHλεΫͷޙ ʹ࣮ߦͯ͠Ͷὑ Ϧελʔτ͢ΔલʹΩϟο γϡΛফ͠ͱ͍ͯͶὑ
  60. ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,

    :service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ QVCMJTIJOHλεΫͷޙ ʹ࣮ߦͯ͠Ͷὑ Ϧελʔτ͢ΔલʹΩϟο γϡΛফ͠ͱ͍ͯͶὑ طଘͷλεΫͷલޙʹ೚ҙͷλεΫΛ )PPL͢Δ
  61. ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do

    _send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨஌͢Δํ๏
  62. ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do

    _send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' σϓϩΠ΍ϩʔϧόοΫͷ։࢝ऴྃ ͷલޙʹ௨஌ΛૹΔ $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨஌͢Δํ๏
  63. ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do

    _send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' σϓϩΠ΍ϩʔϧόοΫͷ։࢝ऴྃ ͷલޙʹ௨஌ΛૹΔ $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨஌͢Δํ๏ ఆٛͨ͠3VCZͷؔ਺ Λݺͼग़͢
  64. ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do

    _send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' σϓϩΠ΍ϩʔϧόοΫͷ։࢝ऴྃ ͷલޙʹ௨஌ΛૹΔ $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨஌͢Δํ๏ ఆٛͨ͠3VCZͷؔ਺ Λݺͼग़͢ 3VCZͰ֦ு͢Δ
  65. σϓϩΠࣗಈԽͷԸܙ ‣ ϛε͕֨ஈʹݮΓɺ։ൃ଎౓্͕͕ͬͨ ‣ σϓϩΠʹର͢Δ৺ཧతোน͕Լ͕ͬͨ ‣ ίʔυԽ͞ΕΔ͜ͱͰ࡞ۀ͕໌֬ʹͳͬͨ

  66. ͢΂͕ͯ͏·͍ͬͨ͘ ΋͏೰ΈͳΜͯແ͍

  67. ͦΜͳΘ͚ͳ͍ ͢΂͕ͯ͏·͍ͬͨ͘ ΋͏೰ΈͳΜͯແ͍

  68. 714ͷ໰୊ ‣ εέʔϧΞ΢τ͢Δͷ͸ͱͯ΋େม ‣ ΍ͬͺΓେखاۀʹ͸ఢΘͳ͍ͷ͔ʜɻ

  69. 1BB4࣌୅ ‣ 1MBUGPSNBTB4FSWJDF ‣ ϢʔβʔͷγεςϜΛ Քಇͤ͞Δࣄ͕Ͱ͖Δ ϓϥοτϑΥʔϜࣗମ ΛɺΠϯλʔωοτܦ ༝ͰαʔϏεͱͯ͠ར ༻Ͱ͖Δܗଶ

    ‣ &OHJOF:BSEʢ೥ʣ ‣ )FSPLVʢ೥ʣ
  70. ͜ͷ࣌୅ ‣ (JUʢ೥ʣ ‣ 3VCZʢ೥ʣ ‣ 1ZUIPOʢ೥ʣ

  71. 1BB4ͷϝϦοτ ‣ ϗετͷ؅ཧ͸αʔϏεࣄۀऀ೚ͤ ‣ ෛՙ෼ࢄ͸ࣗಈ ‣ σϓϩΠ͸AHJUQVTIA͚ͩ

  72. 1BB4ͷӅΕͨϝϦοτ ‣ ϕετϓϥΫςΟεతͳͱ͜ΖΛڧ੍͢Δ ‣ σʔλϕʔεɾΞΫηε༻ͷύεϫʔυ ΛϦϙδτϦʹؚΊͪΌμϝΑὑ ‣ ΞϓϦΛϙʔλϒϧʹ͢Δ͜ͱΛڧ੍͢Δ ‣ ΞοϓϩʔυϑΝΠϧ΍ϩάɺηογϣ

    ϯ৘ใͳͲΛΞϓϦ͔Β෼཭ͤ͞Δ
  73. ΞϓϦͷߏ੒ͷ͞ΒͳΔෳࡶԽ ‣ "MUFSOBUJW+4ͷίϯύΠϧ ‣ "MUFSOBUJWF$44ͷίϯύΠϧ

  74. ͜ͷ࣌୅ ‣ 4BTTʢ೥ʣ ‣ -&44ʢ೥ʣ ‣ $P⒎FFTDSJQUʢ೥ʣ ‣ 3VCZPO3BJMTʹؚ·ΕΔʢ೥ʣ

  75. *BB4࣌୅ ‣ *OGSBTUSVDUVSFBTB4FSWJDF ‣ "NB[PO8FC4FSWJDFਖ਼ࣜެ։ʢ ೥ʣ ‣ (PPHMF$PNQVUF&OHJOFਖ਼ࣜެ։ ʢ೥ʣ

  76. lྑ͍714zͰ͸ແ͔ͬͨ ‣ "1*ʹΑΔૢ࡞ ‣ पลαʔϏεͷॆ࣮ ‣ ෼ࢄετϨʔδʢ4ʣ ‣ σʔλϕʔεʢ%ZOBNP%#ʗ3%4ʣ ‣

    %/4ʢ3PVUFʣ ‣ $%/ʢ$MPVE'SPOUʣ ‣ FUDʜ
  77. lྑ͍714zͰ͸ແ͔ͬͨ ‣ "1*ʹΑΔૢ࡞ ‣ पลαʔϏεͷॆ࣮ ‣ ෼ࢄετϨʔδʢ4ʣ ‣ σʔλϕʔεʢ%ZOBNP%#ʗ3%4ʣ ‣

    %/4ʢ3PVUFʣ ‣ $%/ʢ$MPVE'SPOUʣ ‣ FUDʜ αʔόʔΛ࢖͍ࣺͯͰ͖ΔΑ͏ʹͳͬͨ
  78. *NNVUBCMF*OGSBTUSVDUVSF ‣ αʔόʔͷঢ়ଶΛ؅ཧ͠ͳ͍ ‣ αʔόʔͷ಺༰Λมߋ͢ΔͷͰ͸ͳ͘ɺ ׬੒ͨ͠αʔόʔͱݱߦαʔόʔΛ੾Γ ସ͑Δ

  79. *NNVUBCMF*OGSBTUSVDUVSF ‣ αʔόʔͷঢ়ଶΛ؅ཧ͠ͳ͍ ‣ αʔόʔͷ಺༰Λมߋ͢ΔͷͰ͸ͳ͘ɺ ׬੒ͨ͠αʔόʔͱݱߦαʔόʔΛ੾Γ ସ͑Δ ΞϓϦ͕ϙʔλϒϧʹͳ͔ͬͨΒ࣮ݱ

  80. ͦͷԸܙ ‣ େن໛ʹεέʔϧΞ΢τ͍ͯ͠ΔαʔϏε ͚ͩͰͳ͘ɺϗετͰࣄ଍ΓΔαʔϏε ʹ͢Βɺ҆શʹόʔδϣϯΞοϓ͕Ͱ͖Δ Α͏ʹͳͬͨɻ

  81. ͢΂͕ͯ͏·͍ͬͨ͘ ΋͏೰ΈͳΜͯແ͍

  82. ࠓͷͱ͜Ζ͸Ͷ ͢΂͕ͯ͏·͍ͬͨ͘ ΋͏೰ΈͳΜͯແ͍

  83. ·ͱΊ ‣ σϓϩΠͷख๏ͱ͍͏ࢹ఺Ͱେ·͔ͳྺ࢙ Λͳͧͬͨɻ ‣ Ͳ͏͍ͬͨܦҢͰσϓϩΠͷख๏͕ൃల ͖ͯͨ͠ͷ͔ʁ ‣ Ͳ͏͍ٕͬͨज़͕࢖ΘΕ͖ͯͨͷ͔ʁ ‣

    ͲͷΑ͏ʹࢥ૝͕มΘ͖ͬͯͨͷ͔ʁ
  84. ׬ ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ IUUQTKPJOEJO