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?

Railsの本番環境で最新コードを反映させるには

Posted at

環境

Ubuntu20.4
Ruby 2.6
Rails 5.28
Passenger 6.0.18
Apache2

内容

Railsの本番環境で最新コードを反映させるには、Railsのプロジェクトがあるディレクトリで、つぎのコマンドを実行します。

$touch ./tmp/restart.txt

開発環境では、このようなコマンドを実行しなくても、修正したコードが即反映されるようになっています。

それは、つぎの設定がfalseになっているからです。

config/environment/development.rb
config.cache_classes = false

本番環境では逆にデフォルトでtrueになっています。本番環境でもここの設定をfalseにすれば、最新のコードを反映させると即有効になります。

config/environment/production.rb
config.cache_classes = true

下記のコマンドは何をやっているのかといえば、タイムスタンプだけを最新に更新しています。

$touch ./tmp/restart.txt

Passengerが./tmp/restart.txtのタイムスタンプを常時監視しており、タイムスタンプが最新になれば、アプリケーションサーバーを再起動する仕組みになっています。

上記のコマンドを実行せずに、Apacheを再起動しても最新のコードは反映されますが、普通は、そんなことは行いません。

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?