Sinatra 应用程序 heroku push 中的“未检测到 Procfile”

use*_*760 2 heroku sinatra procfile

我是 Sinatra 和 heroku 的新手。我正在尝试将一个小型 Sinatra 应用程序推送到 heroku,但出现此错误,

 Bundle completed (24.34s)
   Cleaning up the bundler cache.
-----> WARNINGS:
       No Procfile detected, using the default web server (webrick)
       ##I have gone over the docs a few times and added unicorn 
       https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for Ruby  -> console, rake, web

-----> Compressing... done, 17.5MB
-----> Launching... done, v8
Run Code Online (Sandbox Code Playgroud)

这就是我的 gem 文件的样子

   source 'https://rubygems.org'
   ruby '2.1.1'
   gem 'sinatra'
   gem 'sinatra-contrib'
   gem 'typhoeus'
   gem 'pry'
   gem 'rspec'
   gem 'pg'
   gem 'unicorn'
   gem 'thin', '1.2.7'
Run Code Online (Sandbox Code Playgroud)

我已经尝试了很多我在网上看到的东西,但仍然出现此错误。对不起,如果这是一个愚蠢的问题但它让我发疯!如果您想在应用程序中看到更多文件,我很乐意添加它们,我只是不确定要添加哪些文件..

感谢您抽出宝贵时间,感谢您的帮助。

Arm*_*n H 6

Procfile告诉 Heroku 您的应用程序可以运行的不同进程类型(命令)。对于 Ruby 应用程序,Heroku 期望您至少声明一种web进程类型,并且默认情况下还会自动启动两个附加进程:rakeconsole

这意味着您的 Ruby 应用程序应该能够运行一个 Web 进程(这是实际为网页和资产提供服务的进程)、运行rake任务,并为您提供一个类似 shell 的控制台(通过heroku run console在顶层运行来访问它)您的应用程序)。

您需要做的就是Procfile在应用程序的顶级文件夹中添加一个空白文本文件,只需一行代码(如果您使用的是 Rack):

web: bundle exec rackup config.ru -p $PORT
Run Code Online (Sandbox Code Playgroud)

或者,如果您使用的是纯 Sinatra(不带 Rack):

web: bundle exec ruby web.rb -p $PORT
Run Code Online (Sandbox Code Playgroud)

您应该真正阅读Heroku 开发中心的定义 ProcfileThe Procfile以消除任何混淆。