我是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


这就是我的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'


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

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

最佳答案

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

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

您需要做的就是将一个名为heroku run console的空白文本文件添加到应用程序的顶级文件夹中,只需一行代码即可(如果您使用的是Rack):

web: bundle exec rackup config.ru -p $PORT


或者,如果您使用的是纯Sinatra(无机架):

web: bundle exec ruby web.rb -p $PORT


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

关于heroku - Sinatra应用程序heroku push中“未检测到Procfile”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24223476/

10-14 14:44
查看更多