Sinatra app crashes without error on Heroku but works fine locally via
foreman - tips?
I have a simple Sinatra app that is working fine locally with Foreman. But
on Heroku it crashes instantly, without much further information about the
error:
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=
There is no further information about the error
My app is based on https://developers.google.com/+/quickstart/ruby. I have
been trying multiple iterations of Procfile and config.ru to get it to
work, e.g.
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
There was no config.ru included in the app so then I tried creating that
myself:
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=
The Google-coded signin.rb starts up Sinatra, which I think is not a
standard way of launching it as a rack app. It seems that Heroku detects
the rack app but then chokes on some files not being available... Here is
a snippet of signin.rb for good measure:
##
# 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')
No comments:
Post a Comment