あかんわ

覚えたことをブログに書くようにすれば多少はやる気が出るかと思ったんです

HerokuのProcfileの役割

HerokuProcfileは、アプリケーションがどのプロセス*1を使うのか宣言するためのファイルで、アプリケーションのルートディレクトリに配置して利用します。

A Procfile is a mechanism for declaring what commands are run by your application’s dynos on the Heroku platform. It follows the process model.
The file must be placed in the root directory of your application. It will not function if placed in a subdirectory.
Process Types and the Procfile | Heroku Dev Center

久しぶりにheroku createしてgit push heroku masterしたらWARNINGが出て、自分の記憶力の無さを痛感したので、今後も使いそうな宣言方法を書き留めておきます。

$git push heroku master
・
・
・
remote: ###### WARNING:
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
・
・
・

RailsアプリでPumaを使う場合

web: bundle exec puma -C config/puma.rb

DjangoアプリでGunicornを使う場合

web: gunicorn myproject.wsgi --log-file -

PHPアプリの場合

WebサーバにApacheを使う場合
web: vendor/bin/heroku-php-apache2
WebサーバにNginxを使う場合
web: vendor/bin/heroku-php-nginx

Node.jsアプリの場合

web: node index.js

参考記事

devcenter.heroku.com devcenter.heroku.com devcenter.heroku.com devcenter.heroku.com devcenter.heroku.com

*1:Webサーバやアプリケーションサーバなんかのプロセス