-
Notifications
You must be signed in to change notification settings - Fork 17
Flexible Rails Hosting
Flexible Rails Hosting allows you to select the ruby version on the server using capistrano.
Set up rbenv on your development machine.
* Create a file {{{.ruby-version}}} in your project. Contains ruby version, e.g. {{{2.0.0-p0}}} (this is the version rbenv selects when entering the directory) * Add {{{gem 'capistrano-rbenv', '>= 1.0.0' }}} to the '''Gemfile''' * Run {{{bundle}}} * Add {{{require 'capistrano-rbenv' }}} to '''config/deploy.rb''' * Add {{{set :rbenv_ruby_version, "2.0.0-p0"}}} to '''config/deploy.rb''' (this is the version that gets installed on the server) * Add {{{set :rbenv_install_dependencies, false}}} to '''config/deploy.rb''' ([[https://github.com/yyuu/capistrano-rbenv/pull/4|pull request at capistrano-rbenv]])
Further reading
* [[https://github.com/yyuu/capistrano-rbenv|capistrano-rbenv]]
Note: rbenv doesn't use gemsets as rvm does, instead it relies on bundler doing its job. This means prepending every command with 'bundle exec'. Fortunately zsh knows a plugin called 'bundler' out of the box that does that for you magically.
* Add '''gem 'unicorn'''' to the '''Gemfile''' * Run '''bundle''' * Add the following block to '''config/deploy.rb''':
This task install rbenv and ruby-install, configure your shell, builds ruby remotely and creates required directories:
Install application:
You can start the application from your local machine or from the server.
From you local machine, use bundle exec cap deploy ...
* deploy:start * deploy:stop * deploy:graceful_stop * deploy:reload * deploy:restart
On the server, you can use ...
* start * foreground * debug * debug-direct * stop * graceful-stop * reload * restart * pid
Use the cdist types __panter_rails_flexible.
Nginx connects to the unix socket /home/rails/app/current/unix.sock.
Files in /home/rails/app/current/public take precendence (i.e. rails is not asked for those).
Valid for MySQL and PostgreSQL:
* /home/rails/app/shared/config/database.yml is created by cdist and contains the necessary information to connect to the database. * The database '''rails_production''' is created by default * Access is granted to user '''rails'''
* If required/requested, monit will be installed * Supported jobs currently: * dj (delayed_job) * sunspot
The new version [tm] of the new hosting [tm] supports monit configurations defined by the developer.
As a sysadmin, add the following cdist-snippet:
As a developer, create /home/rails/app/shared/config/monit.conf with your configuration.
Monit monitors /home/rails/app/shared/config/monit.conf and restarts itself if it detects a change.
As of 2013-08-08, unicorn is configured using the file ~/.unicorn-config. unicorn_wrapper has been adjusted to support this change. Besides pre loading the app, this change also adds support for unicorn log files:
* /home/rails/app/shared/log/unicorn.stderr.log * /home/rails/app/shared/log/unicorn.stdout.log
See also
* https://newrelic.com/docs/ruby/no-data-with-unicorn
* Use the directory /home/rails/app/shared/protected * See http://wiki.nginx.org/XSendfile for requirements / configuration
* You can use HTTP_X_FORWARDED_SCHEME in rack to find out whether the request came via http or https
* http://www.rubyinside.com/rbenv-a-simple-new-ruby-version-management-tool-5302.html
1.9.3-p392 is the standard version selected by capistrano-rbenv. It probably means you did not specify the version correctly/misspelled the variable name. Ensure it reads as following:
You have to link your database.yml before the asset compilation:
Ensure you have the
part in your deploy.rb.