{"id":4871,"date":"2014-12-03T10:00:11","date_gmt":"2014-12-03T01:00:11","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=4871"},"modified":"2018-11-14T16:33:50","modified_gmt":"2018-11-14T07:33:50","slug":"capistrano3%e3%81%a7%e3%83%97%e3%83%a9%e3%82%a4%e3%83%99%e3%83%bc%e3%83%88%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%8b%e3%82%89%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2014\/12\/03\/capistrano3%e3%81%a7%e3%83%97%e3%83%a9%e3%82%a4%e3%83%99%e3%83%bc%e3%83%88%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%8b%e3%82%89%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e3%81%99%e3%82%8b\/","title":{"rendered":"Capistrano3\u3067\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30c7\u30d7\u30ed\u30a4\u3059\u308b"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u5bfa\u5ca1\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u306f <a title=\"TECHSCORE Advent Calendar 2014\" href=\"http:\/\/www.techscore.com\/blog\/2014\/11\/27\/techscore-advent-calendar-2014\/\">TECHSCORE Advent Calendar 2014<\/a> \u306e 3 \u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<h2>\u305d\u308c\u306f\u9065\u304b\u6614\u3001\u4e16\u754c\u304c\u672a\u3060\u30c7\u30d7\u30ed\u30a4\u30c4\u30fc\u30eb\u3092\u624b\u306b\u5165\u308c\u308b\u524d\u306e\u304a\u8a71\u3002<\/h2>\n<p>\u305d\u306e\u9803\u306e\u30a8\u30f3\u30b8\u30cb\u30a2\u306b\u3068\u3063\u3066\u3001\u30c7\u30d7\u30ed\u30a4\u306f\u795e\u8056\u304b\u3064\u76db\u5927\u306a\u5100\u5f0f\u3067\u3042\u3063\u305f\u3002<br \/>\n\u5100\u5f0f\u306b\u306f\u6c7a\u3057\u3066\u7834\u3063\u3066\u306f\u3044\u3051\u306a\u3044\u6212\u5f8b\u304c\u5b58\u5728\u3057\u305f\u3002<br \/>\n\u300ctar\u3001scp\u3001rake\u306a\u3069\u306e\u9ad8\u5ea6\u3067\u96e3\u89e3\u306a\u546a\u6587\u3092\u99c6\u4f7f\u3057\u3001\u6b63\u3057\u3044\u9806\u5e8f\u3092\u3082\u3063\u3066\u57f7\u308a\u884c\u3046\u3079\u3057\u300d<br \/>\n\u6212\u5f8b\u306f\u5730\u57df\u3001\u6587\u5316\u3001\u5b97\u6559\u306e\u9055\u3044\u306b\u3088\u308a\u3055\u307e\u3056\u307e\u306a\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u304c\u5b58\u5728\u3057\u3001\u5100\u5f0f\u306e\u56f0\u96e3\u3055\u306b\u62cd\u8eca\u3092\u304b\u3051\u308b\u3002<br \/>\n\u3057\u304b\u3057\u3001\u6700\u5f8c\u306f\u5fc5\u305a\u3053\u3046\u7de0\u3081\u304f\u304f\u3089\u308c\u308b\u306e\u3060\u3002<br \/>\n\u300c\u4e00\u5ea6\u546a\u6587\u3092\u9593\u9055\u3048\u305f\u305d\u306e\u6642\u306f\u3001\u5927\u3044\u306a\u308b\u707d\u5384\u304c\u3053\u306e\u4e16\u3092\u8972\u3046\u3067\u3042\u308d\u3046\u300d\u3068\u3002<\/p>\n<p>\u707d\u5384\u3092\u6050\u308c\u305f\u30a8\u30f3\u30b8\u30cb\u30a2\u305f\u3061\u306f\u3001\u9577\u5927\u3067\u91cd\u539a\u306a\u624b\u9806\u66f8\u3092\u4f5c\u308a\u3001\u306a\u3093\u3068\u304b\u30c7\u30d7\u30ed\u30a4\u3092\u4e57\u308a\u5207\u308d\u3046\u3068\u3057\u305f\u3002<br \/>\n\u305d\u308c\u3067\u3082\u306a\u304a\u3001\u624b\u9806\u66f8\u306e\u30d0\u30b0\u3084\u30bf\u30a4\u30d7\u30df\u30b9\u306b\u3088\u308a\u60b2\u5287\u306f\u7e70\u308a\u8fd4\u3055\u308c\u308b\u306e\u3067\u3042\u3063\u305f\u2026\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u5ea6\u91cd\u306a\u308b\u60b2\u5287\u3068\u5207\u308a\u623b\u3057\u306b\u75b2\u5f0a\u3057\u305f\u30a8\u30f3\u30b8\u30cb\u30a2\u305f\u3061\u306b\u5e0c\u671b\u306e\u5149\u304c\u73fe\u308c\u305f\u3002<br \/>\n\u707d\u5384\u3092\u898b\u304b\u306d\u3066\u7acb\u3061\u4e0a\u304c\u3063\u305f\u52c7\u8005\u305f\u3061\u304c\u3001\u30c7\u30d7\u30ed\u30a4\u306b\u7acb\u3061\u5411\u304b\u3046\u6b66\u5668\u3092\u624b\u306b\u5e30\u3063\u3066\u304d\u305f\u306e\u3060\u3002<\/p>\n<p>Capistrano\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u52c7\u8005\u305f\u3061\u304c cap deploy \u3068\u3044\u3046\u546a\u6587\u3092\u5531\u3048\u308b\u3068\u3001\u305f\u3061\u3069\u3053\u308d\u306b\u30c7\u30d7\u30ed\u30a4\u304c\u5b9f\u884c\u3055\u308c\u3066\u3044\u3063\u305f\u3002<br \/>\n\u3053\u3046\u3057\u3066\u5927\u3044\u306a\u308b\u707d\u5384\u306f\u904e\u53bb\u306e\u3082\u306e\u3068\u306a\u308a\u3001\u4e16\u754c\u306f\u5e73\u548c\u306b\u5305\u307e\u308c\u305f\u306e\u3060\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>Capistrano V3 \u3067\u4f7f\u3048\u306a\u304f\u306a\u3063\u305f deploy_via \u30aa\u30d7\u30b7\u30e7\u30f3<\/h2>\n<p>\u3064\u3044\u60aa\u4e57\u308a\u3057\u3066\u3057\u3087\u3046\u3082\u306a\u3044\u5c0f\u8a71\u3092\u66f8\u3044\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306fRails\u306e\u9244\u677f\u30c7\u30d7\u30ed\u30a4\u30c4\u30fc\u30eb <a href=\"http:\/\/capistranorb.com\/\">Capistrano<\/a>\u306e\u30cd\u30bf\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n<p>Capistrano\u306f\u5143\u3005Rails\u306b\u7279\u5316\u3057\u305f\u30c7\u30d7\u30ed\u30a4\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u3057\u3066\u958b\u767a\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\n\u3057\u304b\u3057\u30012013\u5e74\u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305fv3\u304b\u3089\u306fRails\u3078\u306e\u4f9d\u5b58\u3092\u306a\u304f\u3057\u305f\u6c4e\u7528\u7684\u306a\u30c7\u30d7\u30ed\u30a4\u30c4\u30fc\u30eb\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u969b\u3001\u5927\u5e45\u306a\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u5909\u66f4\u304c\u884c\u308f\u308c\u305f\u305f\u3081v2\u304b\u3089\u524a\u3089\u308c\u305f\u6a5f\u80fd\u306f\u5c11\u306a\u304f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u305d\u306e\u4e2d\u306e\u3072\u3068\u3064\u304cdeploy_via\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306f deploy_via :export \u3067\u3001\u30c7\u30d7\u30ed\u30a4\u5b9f\u884c\u6642\u306f\u4e0b\u8a18\u306e\u56f3\u306e\u3088\u3046\u306b\u3001<br \/>\n\u30c7\u30d7\u30ed\u30a4\u5148\u30b5\u30fc\u30d0\u304c\u76f4\u63a5\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30bd\u30fc\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><img src=\"https:\/\/cacoo.com\/diagrams\/FUan6SimJpZctsnU-041D3.png\" alt=\"Capistrano v2 deploy_via: export\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>LAN \u306b\u30ea\u30dd\u30b8\u30c8\u30ea\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u3001\u30c7\u30d7\u30ed\u30a4\u5148\u30b5\u30fc\u30d0\u304b\u3089\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<br \/>\n\u3053\u3093\u306a\u5834\u5408\u306fdeploy_via :copy \u3068\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30d7\u30ed\u30a4\u5143\u3067\u53d6\u5f97\u3057\u305f\u30bd\u30fc\u30b9\u3092\u30c7\u30d7\u30ed\u30a4\u5148\u306b\u8ee2\u9001\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u306e\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><img src=\"https:\/\/cacoo.com\/diagrams\/FUan6SimJpZctsnU-D7B7D.png\" alt=\"Capistrano v2 deploy_via: copy\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u3057\u304b\u3057\u3001Capistrano v3 \u3067\u306f\u3053\u306e\u6a5f\u80fd\u304c\u524a\u9664\u3055\u308c\u305f\u305f\u3081LAN\u4e0a\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u306e\u306f\u96e3\u3057\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\n\u672c\u7a3f\u3067\u306f\u306a\u3093\u3068\u304b\u3057\u3066LAN\u4e0a\u306e\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u65b9\u6cd5\u3092\u691c\u8a0e\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>SSH Port Forwarding<\/h2>\n<p>\u3053\u3053\u3067\u4e00\u65e6\u8a71\u306f\u98db\u3093\u3067\u3001SSH\u306e\u304a\u8a71\u3067\u3059\u3002<\/p>\n<p>SSH\u306b\u306f\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c7\u30a3\u30f3\u30b0\u3068\u3044\u3046\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u69d8\u306b-L\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001ssh\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u30ea\u30c3\u30b9\u30f3\u30dd\u30fc\u30c8\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092<br \/>\nSSH\u30c8\u30f3\u30cd\u30eb\u3092\u901a\u3063\u3066\u30ea\u30e2\u30fc\u30c8\u30db\u30b9\u30c8\u5074\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3078\u8ee2\u9001\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre>ssh -L \uff08\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\uff09\u30ea\u30c3\u30b9\u30f3\u30dd\u30fc\u30c8:\u8ee2\u9001\u5148\u30db\u30b9\u30c8:\u8ee2\u9001\u5148\u30dd\u30fc\u30c8 \u30ea\u30e2\u30fc\u30c8\u30db\u30b9\u30c8\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u72b6\u6cc1\u304c\u3042\u3063\u305f\u3068\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>WAN\u5074\u306eapp2\u30b5\u30fc\u30d0\u306f80\u756a\u30dd\u30fc\u30c8\u3092\u30ea\u30c3\u30b9\u30f3\u3057\u3066\u3044\u308b<\/li>\n<li>\u5916\u90e8\u306b\u306f\u958b\u653e\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u540c\u4e00\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306eapp1\u304b\u3089\u3057\u304b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044<\/li>\n<li>app1\u306b\u306fdeploy\u304b\u3089ssh\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b<\/li>\n<\/ul>\n<p>\u3053\u3053\u3067LAN\u5074\u306edeploy\u30b5\u30fc\u30d0\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001deploy:8080\u3092\u901a\u3057\u3066app2:80\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">ssh -L 8080:app2:80 app1\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img src=\"https:\/\/cacoo.com\/diagrams\/FUan6SimJpZctsnU-8D9D8.png\" alt=\"SSH PortForwarding\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>SSH Remote Port Forwarding<\/h2>\n<p>SSH\u306e\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c7\u30a3\u30f3\u30b0\u306fssh\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u30dd\u30fc\u30c8\u3092\u30ea\u30c3\u30b9\u30f3\u3057\u3001\u30ea\u30e2\u30fc\u30c8\u30db\u30b9\u30c8\u5074\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u8ee2\u9001\u3059\u308b\u6a5f\u80fd\u3067\u3057\u305f\u3002<br \/>\n\u3053\u308c\u3068\u306f\u9006\u306b\u30ea\u30e2\u30fc\u30c8\u30db\u30b9\u30c8\u5074\u306e\u30dd\u30fc\u30c8\u3092\u30ea\u30c3\u30b9\u30f3\u3057\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u8ee2\u9001\u3059\u308b\u6a5f\u80fd\u3082\u5b58\u5728\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306f\u30ea\u30e2\u30fc\u30c8\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c7\u30a3\u30f3\u30b0\u3068\u547c\u3070\u308c\u3001-R\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>ssh -R \uff08\u30ea\u30e2\u30fc\u30c8\u30db\u30b9\u30c8\u306e\uff09\u30ea\u30c3\u30b9\u30f3\u30dd\u30fc\u30c8:\u8ee2\u9001\u5148\u30db\u30b9\u30c8:\u8ee2\u9001\u5148\u30dd\u30fc\u30c8 \u30ea\u30e2\u30fc\u30c8\u30db\u30b9\u30c8\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4eca\u5ea6\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u72b6\u6cc1\u3092\u8003\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n<ul>\n<li>LAN\u5074\u306erepo\u30b5\u30fc\u30d0\u306f80\u756a\u30dd\u30fc\u30c8\u3092\u30ea\u30c3\u30b9\u30f3\u3057\u3066\u3044\u308b<\/li>\n<li>\u5916\u90e8\u306b\u306f\u958b\u653e\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u540c\u4e00\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306edeploy\u304b\u3089\u3057\u304b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044<\/li>\n<li>app1\u306b\u306fdeploy\u304b\u3089ssh\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b<\/li>\n<\/ul>\n<p>\u3053\u306e\u5834\u5408\u3001LAN\u5074\u306edeploy\u30b5\u30fc\u30d0\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001app1:8080\u3092\u901a\u3057\u3066repo:80\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>ssh -R 8080:repo:80 app1\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img src=\"https:\/\/cacoo.com\/diagrams\/FUan6SimJpZctsnU-9AB0E.png\" alt=\"SSH RemotePortForwarding\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>Capistrano v3 \u3067 SSH Remote Port Forwarding<\/h2>\n<p>\u305d\u308d\u305d\u308d\u30aa\u30c1\u304c\u898b\u3048\u3066\u304d\u307e\u3057\u305f\u306d\u3002<br \/>\n\u305d\u3046\u3001Capistrano\u306e\u30c7\u30d7\u30ed\u30a4\u306fSSH\u3092\u4f7f\u3063\u3066\u30c7\u30d7\u30ed\u30a4\u5148\u30b5\u30fc\u30d0\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u3002<br \/>\nSSH\u63a5\u7d9a\u3067\u30ea\u30e2\u30fc\u30c8\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u5229\u7528\u3057\u3066\u3001\u30c7\u30d7\u30ed\u30a4\u5148\u30b5\u30fc\u30d0\u306e\u7279\u5b9a\u306e\u30dd\u30fc\u30c8\u3092\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u3068\u8ee2\u9001\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>Capistrano\u306f\u5185\u90e8\u7684\u306bnet-ssh\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u304a\u308a\u3001\u3053\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u30fb\u30ea\u30e2\u30fc\u30c8\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u306b\u3061\u3083\u3093\u3068\u5bfe\u5fdc\u3057\u3066\u304f\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306fCapistrano\u672c\u4f53\u306b\u624b\u3092\u5165\u308c\u308b\u3053\u3068\u306a\u304fconfig\/deploy.rb\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30c7\u30d7\u30ed\u30a4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:ruby decode:true\"># config\/deploy.rb\r\n\r\n# SSH\u30c8\u30f3\u30cd\u30eb\u3092\u901a\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306e\u3067\u3001\u30db\u30b9\u30c8\u540d\u3092localhost\u306b\u3059\u308b\r\nset :repo_url, 'git:\/\/localhost\/path\/to\/repository.git'\r\n# \u30c7\u30d7\u30ed\u30a4\u5148\u306e9418\u30dd\u30fc\u30c8\u3092repo\u306e9418\u3078\u8ee2\u9001\u3059\u308b\r\nset :remote_forwards, %w{9418:repo:9418}\r\n\r\nnamespace :deploy do\r\n\r\n  # remote_forwards \u8a2d\u5b9a\u306b\u57fa\u3065\u3044\u3066\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\u30bf\u30b9\u30af\r\n  desc 'Starting remote port forwarding'\r\n  task :remote_port_forwarding do\r\n    remote_forwards = fetch(:remote_forwards, [])\r\n    return if remote_forwards.empty?\r\n    on roles(:all) do\r\n      with_ssh do |ssh|\r\n        remote_forwards.each do |arg|\r\n          info \" remote port forwarding #{arg} #{host}\"\r\n          args = arg.split(':').reverse\r\n          args[0] = args[0].to_i if args[0]\r\n          args[2] = args[2].to_i if args[2]\r\n          ssh.forward.remote(*args)\r\n        end\r\n        ssh.exec!(':') #nop\r\n        ssh.loop\r\n      end\r\n    end\r\n  end\r\n  \r\n  # \u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b check, updating\u306e\u524d\u306b\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\r\n  before :check, :remote_port_forwarding\r\n  before :updating, :remote_port_forwarding\r\n\r\nend<\/pre>\n<p>&nbsp;<\/p>\n<p><img src=\"https:\/\/cacoo.com\/diagrams\/FUan6SimJpZctsnU-2F86C.png\" alt=\"Capistrano v3 RemotePortForwarding\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u30d0\u30c3\u30c1\u30ea\u30c7\u30d7\u30ed\u30a4\u3067\u304d\u307e\u3057\u305f\uff01<br \/>\n\u4eca\u56de\u306e\u4f8b\u306fgit\u3067\u3059\u304c\u3001\u7406\u8ad6\u7684\u306b\u306fsvn\u3067\u3082\u4e0a\u624b\u304f\u884c\u304f\u306f\u305a\u3067\u3059\u3002<br \/>\n\u305f\u3060\u3057\u3001http\u306e\u5834\u5408\u306fHOST\u30d8\u30c3\u30c0\u306a\u3069\u306e\u95a2\u4fc2\u3067\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u5834\u5408\u304c\u3042\u308b\u306e\u3067\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u5bfa\u5ca1\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u306f TECHSCORE Advent Calendar 2014 \u306e 3 \u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<br \/>\n\u305d\u308c\u306f\u9065\u304b\u6614\u3001\u4e16\u754c\u304c\u672a\u3060\u30c7\u30d7\u30ed\u30a4\u30c4\u30fc\u30eb\u3092\u624b\u306b\u5165\u308c\u308b\u524d\u306e\u304a\u8a71\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2014\/12\/03\/capistrano3%e3%81%a7%e3%83%97%e3%83%a9%e3%82%a4%e3%83%99%e3%83%bc%e3%83%88%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%8b%e3%82%89%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e3%81%99%e3%82%8b\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[141,143,22],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/4871"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=4871"}],"version-history":[{"count":23,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/4871\/revisions"}],"predecessor-version":[{"id":4923,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/4871\/revisions\/4923"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=4871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=4871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=4871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}