{"id":12141,"date":"2020-11-11T16:18:44","date_gmt":"2020-11-11T07:18:44","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=12141"},"modified":"2023-05-27T22:46:01","modified_gmt":"2023-05-27T13:46:01","slug":"%e3%80%90ruby-on-rails%e3%80%91%e3%80%8ccapistrano%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=12141","title":{"rendered":"\u3010Ruby on Rails\u3011\u300cCapistrano\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>Capistrano\u3068\u306f\uff1f<\/h2>\n<p>\u30c7\u30d7\u30ed\u30a4\u81ea\u52d5\u5316\u30c4\u30fc\u30eb\u3001\u8907\u96d1\u306a\u30c7\u30d7\u30ed\u30a4\u3092\u30b3\u30de\u30f3\u30c9\u4e00\u3064\u3067\u81ea\u52d5\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<h2>\u30e1\u30ea\u30c3\u30c8<\/h2>\n<ul>\n<li>\u30b3\u30de\u30f3\u30c9\u4e00\u3064\u3067\u30a2\u30d7\u30ea\u306e\u66f4\u65b0\u306b\u5bfe\u5fdc\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u30c7\u30d7\u30ed\u30a4\u304c\u975e\u5e38\u306b\u697d\u306b\u306a\u308b\u3002<\/li>\n<li>\u4f5c\u696d\u30df\u30b9\u306e\u30ea\u30b9\u30af\u304c\u6e1b\u308b\u3002<\/li>\n<\/ul>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<h3>Gem\u3078\u306e\u8a18\u8ff0<\/h3>\n<pre class=\"lang:default decode:true\">group :development, :test do\r\n gem 'capistrano'\r\n gem 'capistrano-bundler'\r\n gem 'capistrano-rails'\r\n gem 'capistrano-rbenv'\r\nend<\/pre>\n<h4>capistrano-rails<\/h4>\n<p>\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u969b\u306ebundle install\u7b49\u306e\u305f\u3081\u306b\u5fc5\u8981<\/p>\n<h4>capistrano-rbenv<\/h4>\n<p>rbenv\u3067Ruby\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308b\u5834\u5408\u306b\u5fc5\u8981<\/p>\n<h3>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<pre class=\"lang:default decode:true\">bundle exec cap install<\/pre>\n<h2>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u968e\u5c64<\/h2>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u968e\u5c64<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>root<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u251cCapfile<\/td>\n<td>Capistrano\u5168\u4f53\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3001Capistrano\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092require\u3057\u3066\u3044\u304f\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u251cconfig<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u251cdeploy<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u00a0 \u251cproduction.rb<\/td>\n<td>\u30c7\u30d7\u30ed\u30a4\u74b0\u5883\u5225\u306e\u8a2d\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u00a0 \u2514staging.rb<\/td>\n<td>\u30c7\u30d7\u30ed\u30a4\u74b0\u5883\u5225\u306e\u8a2d\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u2514deploy.rb<\/td>\n<td>prodction\u74b0\u5883\u3001staging\u74b0\u5883\u3069\u3061\u3089\u306b\u3082\u5f53\u3066\u306f\u307e\u308b\u8a2d\u5b9a\u3092\u8a18\u8ff0\u3059\u308b\u3002\u30c7\u30d7\u30ed\u30a4\u306e\u6d41\u308c\u3092\u307e\u3068\u3081\u305f\u3082\u306e\u3002\u3053\u308c\u3092<span style=\"color: #ff0000;\"><strong>\u300c\u30c7\u30d7\u30ed\u30a4\u30ec\u30b7\u30d4\u300d<\/strong><\/span>\u3068\u547c\u3076\u307f\u305f\u3044\u3067\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u2514lib<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u2514capistrano<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u00a0 \u00a0 \u2514tasks<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>root\/config\/deploy\/production.rb or staging.rb<\/h3>\n<ul>\n<li>\u30b5\u30fc\u30d0\u30fc\u30db\u30b9\u30c8\u540d<\/li>\n<li>AWS\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u540d<\/li>\n<li>\u30b5\u30fc\u30d0\u30fc\u30ed\u30fc\u30eb<\/li>\n<li>SSH\u8a2d\u5b9a<\/li>\n<li>\u305d\u306e\u4ed6\u3001\u305d\u306e\u30b5\u30fc\u30d0\u306b\u7d10\u3065\u304f\u4efb\u610f\u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n<h3>root\/config\/deploy.rb<\/h3>\n<ul>\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d<\/li>\n<li>git\u30ec\u30dd\u30b8\u30c8\u30ea<\/li>\n<li>\u5229\u7528\u3059\u308bSCM<\/li>\n<li>\u30bf\u30b9\u30af<\/li>\n<li>\u305d\u308c\u305e\u308c\u306e\u30bf\u30b9\u30af\u3067\u5b9f\u884c\u3059\u308b\u30b3\u30de\u30f3\u30c9<\/li>\n<\/ul>\n<h3>releases\u30d5\u30a9\u30eb\u30c0<\/h3>\n<p>\u30c7\u30d7\u30ed\u30a4\u3055\u308c\u305f\u30a2\u30d7\u30ea\u306f\u3053\u3053\u306b\u307e\u3068\u3081\u3089\u308c\u308b\u3002<\/p>\n<h2>\u30c7\u30d7\u30ed\u30a4<\/h2>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u30c7\u30d7\u30ed\u30a4\u3057\u305f\u3082\u306e\u3092\u518d\u5ea6\u30c7\u30d7\u30ed\u30a4\u3057\u76f4\u3057\u305f\u3044\u5834\u5408\u3082\u540c\u69d8\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">bundle exec cap production deploy<\/pre>\n<h2>\u30c7\u30d7\u30ed\u30a4\u30ec\u30b7\u30d4<\/h2>\n<h3>set [\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u306a\u308b\u30b7\u30f3\u30dc\u30eb]\u00a0 [\u5024]<\/h3>\n<p>Capistrano\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u306b\u4f7f\u3046\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u30aa\u30d7\u30b7\u30e7\u30f3\u540d<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>application<\/td>\n<td>\u30a2\u30d7\u30ea\u540d<\/td>\n<\/tr>\n<tr>\n<td>deploy_to<\/td>\n<td>\u30c7\u30d7\u30ed\u30a4\u5148\u306e\u30d1\u30b9<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>rbenv_type<\/div>\n<\/div>\n<\/td>\n<td>rbenv\u306e\u8a2d\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>rbenv_ruby<\/div>\n<\/div>\n<\/td>\n<td>Ruby\u306e\u30d0\u30fc\u30b8\u30e7\u30f3<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>keep_releases<\/div>\n<\/div>\n<\/td>\n<td>\u30ea\u30ea\u30fc\u30b9\u30d5\u30a9\u30eb\u30c0\u3092\u3044\u304f\u3064\u307e\u3067\u4fdd\u6301\u3059\u308b\u304b\u3002<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>keep_assets<\/div>\n<\/div>\n<\/td>\n<td>\u904e\u53bb\u306e\u30ea\u30ea\u30fc\u30b9\u3067\u4f5c\u3089\u308c\u305fassets\u306e\u30d5\u30a9\u30eb\u30c0\u6570\u3092\u4f55\u4e16\u4ee3\u6b8b\u3059\u306e\u304b\u306e\u8a2d\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>branch<\/td>\n<td>\u30d6\u30e9\u30f3\u30c1\u306e\u8a2d\u5b9a\u304c\u3057\u305f\u3044\u5834\u5408\u306b\u4f7f\u7528\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>log_level<\/div>\n<\/div>\n<\/td>\n<td>Capistrano\u306e\u51fa\u529b\u30ed\u30b0\u306e\u5236\u5fa1<\/td>\n<\/tr>\n<tr>\n<td>pty<\/td>\n<td>sudo\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306ftrue\u306b\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>logrotate_app_log_rotation<\/div>\n<\/div>\n<\/td>\n<td>Rails\u95a2\u9023\u306e\u30ed\u30b0\u306e\u4fdd\u5b58\u6570<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>slack_url<\/div>\n<\/div>\n<\/td>\n<td>slack\u901a\u77e5\u5148\u306eURL<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>slack_channel<\/div>\n<\/div>\n<\/td>\n<td>slack\u901a\u77e5\u5148\u306e\u30c1\u30e3\u30f3\u30cd\u30eb<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>sidekiq_config<\/div>\n<\/div>\n<\/td>\n<td>sidekiq\u306e\u8a2d\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>whenever_roles<\/div>\n<\/div>\n<\/td>\n<td>whenever\u306e\u8a2d\u5b9a\u3001capistrano\u306ecron\u306e\u30ed\u30fc\u30eb\u8a2d\u5b9a\u304c\u3067\u304d\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>environment_variables_file<\/td>\n<td>\n<div>\n<div>crontab\u7b49\u3067rails\u3092\u8d77\u52d5\u3059\u308b\u969b\u306b\u5fc5\u8981\u3068\u306a\u308b\u74b0\u5883\u5909\u6570\u3092\u683c\u7d0d\u3057\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>append<\/h3>\n<h4>append :linked_files<\/h4>\n<p>\u300cgit\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u306a\u3044\u300d or \u300cgit\u306e\u3082\u306e\u3092\u4f7f\u3044\u305f\u304f\u306a\u3044(\u672c\u756a\u74b0\u5883\u7279\u6709\u306e\u3082\u306e)\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">append :linked_files, 'config\/database.yml','config\/secrets.yml', 'config\/puma.rb','config\/master.key'<\/pre>\n<h4>append :linked_dirs<\/h4>\n<p>git\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u306a\u3044\u30ed\u30b0\u3001UNIX\u30bd\u30b1\u30c3\u30c8\u3084pid\u306a\u3069\u304c\u683c\u7d0d\u3055\u308c\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u6307\u5b9a<\/p>\n<pre class=\"lang:default decode:true\">append :linked_dirs, 'log', 'tmp\/pids', 'tmp\/cache', 'tmp\/sockets'<\/pre>\n<h3>namespace<\/h3>\n<p>Capistrano2.x\u4ee5\u964d\u306f\u5168\u3066\u306e\u30bf\u30b9\u30af\u304c\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u5316\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">namespace :\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u540d do\r\n  task :\u30bf\u30b9\u30af1 do\r\n  end\r\n\r\n  task :\u30bf\u30b9\u30af2 do\r\n  end\r\nend\r\n<\/pre>\n<h4>task<\/h4>\n<p>\u5b9f\u969b\u306b\u51e6\u7406\u3092\u8a18\u8f09\u3057\u305f\u3082\u306e\u3002<\/p>\n<div>\n<h4>invoke<\/h4>\n<p>\u30bf\u30b9\u30af\u3092\u8a2d\u5b9a\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3002namespace\u304c\u5fc5\u9808\u3002<\/p>\n<h3>execute<\/h3>\n<div>\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067\u7279\u5b9a\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Capistrano\u3068\u306f\uff1f \u30c7\u30d7\u30ed\u30a4\u81ea\u52d5\u5316\u30c4\u30fc\u30eb\u3001\u8907\u96d1\u306a\u30c7\u30d7\u30ed\u30a4\u3092\u30b3\u30de\u30f3\u30c9\u4e00\u3064\u3067\u81ea\u52d5\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002 \u30e1\u30ea\u30c3\u30c8 \u30b3\u30de\u30f3\u30c9\u4e00\u3064\u3067\u30a2\u30d7\u30ea\u306e\u66f4\u65b0\u306b\u5bfe\u5fdc\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u30c7\u30d7\u30ed\u30a4\u304c\u975e\u5e38\u306b\u697d\u306b\u306a\u308b\u3002 \u4f5c\u696d\u30df\u30b9\u306e\u30ea\u30b9\u30af\u304c\u6e1b\u308b\u3002 \u30a4\u30f3 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[36],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/12141"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12141"}],"version-history":[{"count":16,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/12141\/revisions"}],"predecessor-version":[{"id":20506,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/12141\/revisions\/20506"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12141"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}