Rails/Uberspacify: 503 Service Temporarily Unavailable

2.8k views Asked by At

I am testing uberspace.de with uberspacify, a capistrano receipes collection. Before I started with uberspacify I configured the server as described in the documentation provided by uberspace. My RubyOnRails app just launched nicely. Now that I deployed via uberspacify, the following error is written in /var/www/virtual/john/logs/error_log:

[error] (111)Connection refused: proxy: HTTP: attempt to connect to 127.0.0.1:44477 (*) failed

Note that the port 44477 is a different each time I deploy.
The website itself states:

503 Service Temporarily Unavailable
The server is temporarily unable to service your request due to 
maintenance downtime or capacity problems. Please try again later.
Apache/2.2.15 (CentOS) Server at foobar.phoenix.uberspace.de Port 443

Here is the Capfile I prepared:

# Capfile
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks

Here is the configuration in deploy.rb:

# config/deploy.rb

# include uberspacify base recipes
require "uberspacify/base"

# comment this if you don"t use MySQL
require "uberspacify/mysql"

# the Uberspace server you are on
server "phoenix.uberspace.de", :web, :app, :db, :primary => true

# your Uberspace username
set :user, "john"

# a name for your app, [a-z0-9] should be safe, will be used for your gemset,
# databases, directories, etc.
set :application, "foobar"

# the repo where your code is hosted
set :scm, :git
set :repository, "[email protected]:obama/#{application}.git"
set :branch, "master"

# optional stuff from here

# By default, your app will be available in the root of your Uberspace. If you
# have your own domain set up, you can configure it here
# set :domain, "www.dummyapp.com"

# By default, uberspacify will generate a random port number for Passenger to
# listen on. This is fine, since only Apache will use it. Your app will always
# be available on port 80 and 443 from the outside. However, if you"d like to
# set this yourself, go ahead.
# set :passenger_port, 55555

# By default, Ruby Enterprise Edition 1.8.7 is used for Uberspace. If you
# prefer Ruby 1.9 or any other version, please refer to the RVM documentation
# at https://rvm.io/integration/capistrano/ and set this variable.
set :rvm_ruby_string, "1.9.3@#{application}"

I ran the following commands:

$ bundle exec cap deploy:setup
$ bundle exec cap deploy:migrations

I wonder if uberspacify takes care of all the configuration. The uberspace tutorial for RubyOnRails works with fcgi and an .htaccess with rewrite rules. Also they do not use rvm.

Here is the Gemfile of the application:

source 'https://rubygems.org'

ruby '1.9.3'
gem 'rails', '~> 3.2.13'
gem 'counter_culture', git: 'https://github.com/dorilla/counter_culture'
gem 'jquery-rails', '~> 3.0.2'
gem 'therubyracer', '~> 0.11.4', require: 'v8'
gem 'attribute_normalizer', '~> 1.1.0'
gem 'pry', '~> 0.9.12.2'

# Parsing ShapeFiles
gem 'rgeo', '~> 0.3.20'
gem 'rgeo-shapefile', '~> 0.2.3'
gem 'georuby', '~> 2.0.0'
gem 'dbf', '~> 2.0.6'
gem 'gdal', '~> 0.0.5'

gem 'capistrano', '~> 2.15.5'
gem 'uberspacify', '~> 0.9.3'
gem 'mysql2', '~> 0.3.13'

group :assets do
  gem 'sass-rails', '~> 3.2.5'
  gem 'coffee-rails', '~> 3.2.2'
  gem 'uglifier', '~> 2.1.1'
end

group :development do
  gem 'debugger', '~> 1.6.0'
end

group :development, :test do
  gem 'sqlite3', '~> 1.3.7'
  gem 'rspec-rails', '~> 2.14.0'
  gem 'rspec-smart-formatter', '~> 0.0.4', require: false
  gem 'factory_girl_rails', '4.2.1'
  gem 'factory_girl_extensions', '2.1.0'
end

group :production do
  gem 'mysql2', '~> 0.3.13'
end

Of interest might be that I needed to install the gdal library via the toast package manager, via: $ toast arm gdal before I could successfully install $ gem install gdal. This gem is needed for parsing ShapeFiles.


I noticed that there is no ~/.passenger directory after deploy:setup and deploy:migrations successfully processsed.

2

There are 2 answers

1
JJD On BEST ANSWER

Problem solved with the great help of @patheticpat !!!

Here are the steps that were helpful to analyse the problem on the server.

  • To check if the webserver was running at all run $ curl http://localhost:{PORT}. The port can be found in ~/html/.htaccess or in ~/service/rails-{yourapp}/run.
  • To manually start the server execute $ ~/service/rails-{yourapp}/run and watch out for errors.
  • The current deployment can be found in /var/www/virtual/$USER/rails/{yourapp}/current.
  • To start Passenger manually run $ bundle exec passenger start -p $PORT -e production
  • To start Passenger as a service run $ svc -u ~/service/rails-{yourapp}
  • To stop Passenger service run $ svc -d ~/service/rails-{yourapp}

In this process of trial and error we found out that there is PATH problem and we noticed that ~/service/rails-{yourapp}/run sources $HOME/.bash_profile as can be seen here. To mention is that I use zsh in combination with oh-my-zsh and custom dotfiles. We noticed that I already have configured rvm in ~/.zshrc. This file already contains a source command:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

We found out that this actually hinders rvm to put the same statement into ~/.bash_profile as it is already documented here.

To summarize: If you remove the rvm configuration from your custom dotfiles uberspacify will perfectly setup and launch the webserver.


@uberspacify: I suggest you rewrite the rvm script to watch out for the warning mentioned here and react appropriate.

3
jan On

I am the author of Uberspacify. It seems that Passenger with your Rails app hasn't started (yet). This is why Apache reports "Connection refused" on port 44477 -- which is the port that uberspacify chose randomly for internal communication between Passenger and Apache.

To debug this, you might want to check out the log files in /var/www/virtual/< your username>/rails/<your app>/shared/log.

Also, please be sure to "undo" any configuration changes you did according to the instructions by Uberspace. Their instructions are intended for an FCGI-only deployment and have nothing to do (and are most likely incompatible) with Uberspacify. The only preconditions for using Uberspacify are a regular Rails app and an Uberspace account.