Sinatra应用程序在Heroku上没有错误崩溃,但通过工头在本地工作正常 - 提示?

时间:2013-09-17 19:08:19

标签: ruby heroku oauth sinatra

我有一个简单的Sinatra应用程序,在Foreman本地工作正常。但是在Heroku上它会立即崩溃:

2013-09-17T18:52:37.449716+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=rfcstd.herokuapp.com fwd="38.122.223.90" dyno= connect= service= status=503 bytes=
2013-09-17T18:55:29.671059+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=rfcstd.herokuapp.com fwd="38.122.223.90" dyno= connect= service= status=503 bytes=

没有关于错误的进一步信息。

我的应用基于https://developers.google.com/+/quickstart/ruby。我一直在尝试Procfile和config.ru的多次迭代,以使其工作,例如。

Procfile.rb >
web: bundle exec ruby signing.rb -p $PORT

Answer:
Starting process with command `bundle exec rackup config.ru -p 14469`
configuration /app/config.ru not found

应用程序中没有包含config.ru,所以我尝试自己创建:

Procfile.rb >
web: bundle exec rackup ./config.ru -p $PORT
OR
web: bundle exec rackup config.ru -p $PORT

Config.ru >
require './signin.rb'
run Sinatra::Application

Answer:
at=error code=H10 desc="App crashed" method=GET path=/ host=rfcstd.herokuapp.com fwd="38.122.223.90" dyno= connect= service= status=503 bytes=

Google编码的signin.rb启动了Sinatra,我认为这不是将其作为机架应用启动的标准方式。似乎Heroku检测到机架应用程序,但随后扼杀了一些无法使用的文件......以下是signin.rb的一小段内容:

##
# The Google+ Ruby Quickstart lets you get started with the Google+ platform
# in a few minutes.
#
# The app demonstrates:
#  * Using the Google+ Sign-In button to get an OAuth 2.0 refresh token.
#  * Exchanging the refresh token for an access token.
#  * Making Google+ API requests with the access token, including getting a
#    list of people that the user has circled.
#  * Disconnecting the app from the user's Google account and revoking tokens.
#
# Author: class@google.com (Gus Class)
require 'bundler/setup'
require 'base64'
require 'rubygems'
require 'json'
require 'sinatra'
require 'google/api_client'
require 'google/api_client/client_secrets'
require 'net/https'
require 'uri'
require 'open-uri'
use Rack::Session::Pool, :expire_after => 86400 # 1 day

# Configuration
# See the README.md for getting the OAuth 2.0 client ID and
# client secret.

# Configuration that you probably don't have to change
APPLICATION_NAME = 'MyAppName'
PLUS_LOGIN_SCOPE = 'https://www.googleapis.com/auth/plus.login'
#set :port, 5000

# Build the global client
$credentials = Google::APIClient::ClientSecrets.load
$authorization = Signet::OAuth2::Client.new(
    :authorization_uri => $credentials.authorization_uri,
    :token_credential_uri => $credentials.token_credential_uri,
    :client_id => $credentials.client_id,
    :client_secret => $credentials.client_secret,
    :redirect_uri => $credentials.redirect_uris.first,
    :scope => PLUS_LOGIN_SCOPE)
$client = Google::APIClient.new(:application_name => APPLICATION_NAME, :application_version => '0.1')

0 个答案:

没有答案