0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【AWS】Capistranoを用いた自動デプロイの注意点

Last updated at Posted at 2020-12-13

概要

  • 発生した問題のエラーログ
  • デプロイ前にunicornを停止する
  • EC2インスタン再起動の際にはWEBサーバーを再起動する

発生した問題のエラーログ

  • TOPページ意外のページへ遷移するとエラーが発生
    • N+1問題修正のためにコントローラーを修正した後に発生
    • DB関連には問題なさそう・・・
production.log
[log]$ tail -f production.log 
DEBUG -- :    (0.1ms)  SELECT GET_LOCK('303837913129081065', 0)
DEBUG -- :    (19.0ms)  SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
DEBUG -- :   ActiveRecord::InternalMetadata Load (1.5ms)  SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1
DEBUG -- :    (0.1ms)  SELECT RELEASE_LOCK('303837913129081065')
DEBUG -- :    (14.4ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
DEBUG -- :    (0.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
DEBUG -- :    (0.1ms)  SELECT GET_LOCK('303837913129081065', 0)
DEBUG -- :    (1.4ms)  SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
DEBUG -- :   ActiveRecord::InternalMetadata Load (0.7ms)  SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1
DEBUG -- :    (0.1ms)  SELECT RELEASE_LOCK('303837913129081065')

解決方法

  • appサーバーを停止させてからデプロイ
$ ps aux | grep unicorn
$ kill [process number]

備考

  • EC2インスタンス再起動の際にはWEBサーバーの再起動が必要
$ sudo systemctl restart mariadb 
$ sudo systemctl restart nginx

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?