capistranoでデプロイ完了後、リモートサーバにあるunicornを立ち上がるためには、何かコマンドが必要なのか??
capistranoを使って、nguni+unicorn+railsにデプロイしたところ、うまくデプロイが完了しているようなのですが、unicornの画面が立ち上がりません。デプロイ状況の出力(下記参照)を見ると、unicornがkillされてるせいなのか?と思いました。
そこで、deploy:finishedの後に「unicornのrestart」を行なうように設定し直しましたが、こちらもダメでした。
確認のためにリモートサーバーのに入って、ps aus | grep unicorn
で確認したところ、unicornはたちあがっているようです。
capistranoのログに出てくるkillって何なんでしょうか?それと、ローカルサーバーから何故unicornの画面が確認できないんでしょうか?(何か必要なコマンドがあるのでしょうか?)
●デプロイの出力の最後付近の状況
00:12 deploy:symlink:release
01 ln -s /var/www/awesome-events/releases/20180613094719 /var/www/awesome-events/releases/current
✔ 01 ops@vagrant.local 0.009s
02 mv /var/www/awesome-events/releases/current /var/www/awesome-events
✔ 02 ops@vagrant.local 0.009s
00:12 unicorn:start
unicorn is running...
unicorn restarting...
01 kill -s USR2cat /var/www/awesome-events/current/tmp/pids/unicorn.pid
✔ 01 ops@vagrant.local 0.012s
00:12 deploy:cleanup
Keeping 5 of 6 deployed releases on vagrant.local
01 rm -rf /var/www/awesome-events/releases/20180612225508
✔ 01 ops@vagrant.local 0.084s
00:12 deploy:log_revision
01 echo "Branch master (at 7c8fc0327d226c2c847e04285d417535d2f9baee) deployed as release 20180613094719 by takashi_kageyama" >> /var/www/awesom…
✔ 01 ops@vagrant.local 0.009s
●上記のデプロイ時のconfig/deploy.rb
lock "~> 3.10.2"
set :application, "awesome_events"
set :repo_url, "https://github.com/takakag/awesome_events.git"
set :deploy_to, "/var/www/awesome-events"
set :keep_releases, 5
set :default_env, {
rbenv_root: '/home/ops/.rbenv',
path: '/home/ops/.rbenv/shims:/home/ops/.rbenv/bin:$PATH'
}
set :linked_dirs, fetch(:linked_dirs,[]).push('tmp/pids')
set :unicorn_rack_env, "none"
set :unicorn_config_path, 'config/unicorn.rb'
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
invoke 'unicorn:restart'
end
end
●上記のconifg/deploy.rbの下から6行目を以下のとおり修正して、デプロイしみる。
after 'deploy:finished', 'deploy:restart'
→デプロイの結果(最後は、killで終わっている。)
00:09 deploy:assets:backup_manifest
01 mkdir -p /var/www/awesome-events/releases/20180613102301/assets_manifest_backup
✔ 01 ops@vagrant.local 0.009s
02 cp /var/www/awesome-events/releases/20180613102301/public/assets/.sprockets-manifest-06c576762cc73a488eb99cae15076b29.json /var/www/awesome-…
✔ 02 ops@vagrant.local 0.011s
00:09 deploy:migrate
[deploy:migrate] Runrake db:migrate
00:09 deploy:migrating
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate
✔ 01 ops@vagrant.local 1.882s
00:11 deploy:symlink:release
01 ln -s /var/www/awesome-events/releases/20180613102301 /var/www/awesome-events/releases/current
✔ 01 ops@vagrant.local 0.009s
02 mv /var/www/awesome-events/releases/current /var/www/awesome-events
✔ 02 ops@vagrant.local 0.009s
00:11 deploy:cleanup
Keeping 5 of 6 deployed releases on vagrant.local
01 rm -rf /var/www/awesome-events/releases/20180613092838
✔ 01 ops@vagrant.local 0.079s
00:11 deploy:log_revision
01 echo "Branch master (at 7c8fc0327d226c2c847e04285d417535d2f9baee) deployed as release 20180613102301 by takashi_kageyama" >> /var/www/awesom…
✔ 01 ops@vagrant.local 0.009s
00:11 unicorn:start
unicorn is running...
unicorn restarting...
01 kill -s USR2cat /var/www/awesome-events/current/tmp/pids/unicorn.pid
✔ 01 ops@vagrant.local 0.016s
unicornの接続確認結果
ops@ubuntu-14:~$ lsof -i
PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 15311 ops 8u IPv4 46505 0t0 TCP localhost:3000 (LISTEN)
ruby 15320 ops 8u IPv4 46505 0t0 TCP localhost:3000 (LISTEN)
ruby 15324 ops 8u IPv4 46505 0t0 TCP localhost:3000 (LISTEN)
ops@ubuntu-14:~$ ps -aux |grep unicorn
ops 15311 0.1 7.9 265072 81048 ? Sl 10:58 0:01 unicorn master -c config/unicorn.rb -E none -D
ops 15320 0.0 7.5 266100 76420 ? Sl 10:58 0:00 unicorn worker[0] -c config/unicorn.rb -E none -D
ops 15324 0.0 7.5 266100 76420 ? Sl 10:58 0:00 unicorn worker[1] -c config/unicorn.rb -E none -D
ops 15465 0.0 0.0 11744 920 pts/1 S+ 11:21 0:00 grep --color=auto unicorn
curl localhost:3000の実効結果
* Documentation: https://help.ubuntu.com/
New release '16.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Mon Jun 18 22:53:20 2018 from 10.0.2.2
ops@ubuntu-14:~$ curl localhost:3000
<!DOCTYPE html>
<html>
<head>
<title>AwesomeEvents</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" media="all" href="/assets/application-1c377ed8d3bda9e32406b2ac529612d55b8d1cbe834b36be890686fbf8ad4d9f.css" data-turbolinks-track="true" />
<script src="/assets/application-8d774a7a7b28ba38899760306a48ae0ae90898e49be7fb3b365fe604327f9f77.js" data-turbolinks-track="true"></script>
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="n9PBnBwJHQJg9jnrrs7jkz1xlhvaTmBpy5MpvfQr13A8VX34HM1otVNEPdatqo/KTdD+J8RCLhfczihQ37KleA==" />
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">AwesomeEvents</a>
</div>
<div class="cllapse navbar-collapse" id="bs-example-navbar-collapse-1" %>
<ul class="nav navbar-nav navbar-right">
<li><a href="/events/new">イベントを作る</a></li>
<li><a href="/auth/twitter">twitterからログイン</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<h1>Welcome#index</h1>
<p>Find me in app/views/welcome/index.html.erb</p>
<div class="page-header">
<h1>イベント一覧</h1>
</div>
<form class="well" id="event_search" action="/" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓" />
<div class="form-group">
<label for="q_name_cont">イベント名</label>
<input class="form-control" type="text" name="q[name_cont]" id="q_name_cont" />
</div>
<div class="form-group">
<label for="q_start_time_gteq">開催日</label>
<div>
<select id="q_start_time_gteq_1i" name="q[start_time_gteq(1i)]">
<option value="">年</option>
<option value="2018" selected="selected">2018</option>
<option value="2019">2019</option>
</select>
<select id="q_start_time_gteq_2i" name="q[start_time_gteq(2i)]">
<option value="">月</option>
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
<option value="4">4月</option>
<option value="5">5月</option>
<option value="6" selected="selected">6月</option>
<option value="7">7月</option>
<option value="8">8月</option>
<option value="9">9月</option>
<option value="10">10月</option>
<option value="11">11月</option>
<option value="12">12月</option>
</select>
<select id="q_start_time_gteq_3i" name="q[start_time_gteq(3i)]">
<option value="">日</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19" selected="selected">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
〜
</div>
</div>
<input type="submit" name="commit" value="検索" class="btn btn-default" data-disable-with="検索" />
</form>
<div class="list-group">
</div>
</div>
</body>
</html>