やりたいこと
引き続き、infratasterでhttp://endpoent-xxx.reviewapps.speee.jp のroutingがテストできるようにする。
そのために確認したいこと
テスト環境において、下記の挙動となることを確認したい
- http://endpoint-xxx.reviewapps.speee.jpにアクセスする
- すると nginxにて、http://127.0.0.1:80 に飛ばされる(参考)
- 今のテストデータを利用した場合
- 127.0.0.1:80 では、テスト用のスクリプトが動いてて、なんらかのレスポンスを返してくれる。
1pomo 10:20 - 10:45
docker-compose downで、誤ってテスト用データ消しちゃったので、もう一度作り直す。
% docker-compose up -d % mysql -u root -A -h 127.0.0.1 -P 33306 mysql> create database revieee_development; Query OK, 1 row affected (0.00 sec) mysql> use revieee_development; Database changed mysql> create table endpoints(id int, ip varchar(15), port int, task_id int); Query OK, 0 rows affected (0.02 sec) mysql> insert into endpoints(id, ip, port, task_id) values (1, '127.0.0.1', 80, 1); Query OK, 1 row affected (0.00 sec)
できた。とりあえず挙動を確認したい。curlを実行する。
% curl -H "Host: endpoint-1.reviewapps.speee.jp" http://127.0.0.1 [10:24:28] <html> <head><title>500 Internal Server Error</title></head> <body bgcolor="white"> <center><h1>500 Internal Server Error</h1></center> <hr><center>nginx/1.11.13</center> </body> </html>
なぞのエラー。 エラーログはこんな感じ。
revieee_nginx_container | 2017/07/11 01:24:28 [error] 5#0: *2128 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: ~^endpoint-(?<endpoint_id>\d+)\.reviewapps\.speee\.jp$, request: "GET / HTTP/1.0", upstream: "http://127.0.0.1:80/", host: "endpoint-1.reviewapps.speee.jp"
キャッシュが問題かも知れないので、それを消してみる。
% curl -H "Host: endpoint-1.reviewapps.speee.jp" http://127.0.0.1/revieee/clear
そのときのログはこちら。
revieee_nginx_container | 2017/07/11 01:27:44 [error] 5#0: *2175 mrb_run failed: return 500 HTTP status code to client: error: /usr/local/nginx/hook/clear.rb:21: lmc_set_lock_flag: Failed to lock shared memory--may be corrupt! (Cache::ShmLockFailed), client: 172.21.0.2, server: ~^endpoint-(?<endpoint_id>\d+)\.reviewapps\.speee\.jp$, request: "GET /revieee/clear HTTP/1.1", host: "endpoint-1.reviewapps.speee.jp" nginx-proxy | nginx.1 | endpoint-1.reviewapps.speee.jp 172.21.0.1 - - [11/Jul/2017:01:27:44 +0000] "GET /revieee/clear HTTP/1.1" 500 194 "-" "curl/7.43.0"
なぞのエラー。とりあえず動いていたころまでコードを戻してみるが、やっぱりダメだった。 コードでは無いところで問題が発生していそう。
mrb_run failed: return 500 HTTP status code to client: error: /usr/local/nginx/hook/clear.rb:21: lmc_set_lock_flag: Failed to lock shared memory--may be corrupt!
このエラーから問題を探っていこう。 同じようなエラーに遭遇している人があんまりいないし、issueも無いのでコードを読む。
https://github.com/matsumotory/mruby-localmemcache/blob/master/src/localmemcache.c#L17-L28
3pomo 14:10 - 14:35
このあたりにファイルが作られてた。 エラーログを見るとshared memoryが壊れているらしい。 なので、一旦消してみる。このエラーに戻ってきた。
% curl -H "Host: endpoint-1.reviewapps.speee.jp" http://127.0.0.1/ [15:39:03] <html> <head><title>400 Request Header Or Cookie Too Large</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <center>Request Header Or Cookie Too Large</center> <hr><center>nginx/1.11.13</center> </body> </html>
やっぱり原因が不明….
今日の開発の振り返り
エラーに振り回されてしまった。 知らない分野でも、もう少し狙いをつけて調査する癖を付けなければ。
とりあえず、動くところまで戻した。 エラーが起きた原因を考えながら、もう一度実装してみる。 Nginx for revieee bugfix by selmertsx · Pull Request #74 · speee/webapp-revieee · GitHub