geordi cucumber
: Only attempt @solo run when the specified files contain the @solo tag, skip @solo run if any filename is passed with a line number (e.g. features/example.feature:3
)geordi deploy
: Find stages by their prefix (e.g. s
-> staging, m
-> makandra), bundle if needed, check the selected stage existsgeordi server
: Takes port as argument (e.g. geordi ser 3001
), option --public
(-P
) starts the server with -b 0.0.0.0
to make it accessible from other machines in the local network, e.g. ...Capistrano is by default configured to exclude the gems of the groups development
and test
when deploying to the stages production
and staging
. Whenever you create custom groups in your Gemfile
, make sure to exclude these, if they should not be deployed to the servers. The gems of these groups might not be loaded by rails, however, the deployment process will take longer as the gems will be downloaded and installed to the server.
e.g. to exclude the groups cucumber
and deploy
, add the following to `config/deploy/production.rb...
When building a web application, one is tempted to claim it "done" too early. Make sure you check this list.
Desktops, tablets and mobile devices have all different screen resolutions. Does your design work on each of them?
Tool to show you which gems are slow to load:
➜ git:(master) ✗ bundle exec bumbler
[################################################# ]
(49/65) travis-lint...
Slow requires:
110.21 render_anywhere
147.33 nokogiri
173.83 haml
179.62 sass-rails
205.04 delayed_job_active_record
286.76 rails
289.36 mail
291.98 capistrano
326.05 delayed_job
414.27 pry
852.13 salesforce_bulk_api
To install gems Bundler needs to be able to talk to https://api.rubygems.org
.
If you are behind a proxy you can use the https_proxy
environment variable:
https_proxy=http://myproxy:123 bundle install
Note that if there is no https_proxy
env variable, Bundler will also look for a http_proxy
env variable.
Ideally the server you're deploying on exports an https_proxy
variable for all shells.
If you don't have control over the server setup, you can also add this to your Capistrano config:
...
Changes:
@solo
will be excluded from parallel runs, and run sequentially in a second run:migrations
on Capistrano 3).firefox-version
file to set up a test firefox. By default now uses the system Firefox/a test Chrome/whatever and doesn't print warnings any more.geordi deploy --no-migrations
(aliased -M
): Deploy with `cap ...Note
The maintenance mode is enabled on all application server as soon as the file
/public/system/maintenance.html
is present.
Add this line to your application's Gemfile:
gem 'capistrano', '~> 3.0'
gem 'capistrano-maintenance', '~> 1.0'
Add this line to you application's Capfile:
require 'capistrano/maintenance'
Present a maintenance page to visitors. Disables your application's web interface by writing a #{maintenance_basename}.html
file to each web server. The servers m...
Changes:
geordi
) and mark others as deprecatedQuick check: bin/rails runner 'puts Nokogiri::VersionInfo.new.libxml2_using_system?'
Nokogiri uses vendored libxml2 since version 1.6.0, which means that each time a new issue with libxml2 occurs, you have to update nokogiri itself. Another approach is to use the system lib again, as it patches the libxml2 library with periodically system updates.
bundle config --local build.nokogiri --use-system-libraries
.bundle
is not gitignored and .bundle/config contains
these lines:...
I recommend to go straight to 2.1.5+
without intermediate steps. Otherwhise you burden yourself with unnecessary work of encoding problems.
Issues you may encounter:
.ruby-version
file to 2.1.5
ruby-debug
and use e.g. byebug
oniguruma
fastercsv
mysql
with mysql2
2.12.0
to ~>2.12
when bound for Ruby 1.8.7
and remove obsolete explicite Gemfile entries for net-scp
and net-ssh
if present.If you'd like to preview the crontab that whenever will deploy, run the following:
bundle exec whenever
This will print the cron syntax without modifying your local crontab.
In Capistrano 2, directories in shared_children
used to be symlinked to the shared
directory during the finalize_update
task.
# <capistrano>/lib/capistrano/recipes/deploy.rb
_cset :shared_children, %w(public/system log tmp/pids)
# ...
task :finalize_update, :except => { :no_release => true } do
# ...
shared_children.map do |d|
run "ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}" # <-- symlinks only the last s...
Note: Making a reverse proxy with nginx is much more straightforward.
A reverse proxy is a "man in the middle" server that tunnels requests to another server. You can use for things like:
Capistrano 3 is a major rework of the framework and requires several adjustments to your deploy configuration files. The biggest change is that they moved away from their custom DSL and use Rake
instead. For connecting with and operating on the servers, they bring a new gem SSHKit
which does the heavy lifting. It's SSHKit's DSL that is used anywhere inside the Rake tasks. See #Resources at the bottom for examples.
For migration from 2 to 3, follow this tutorial: [Capistrano 3 Upgrade Guide](https://semaphorec...
You can hook into Slack when using Capistrano for deployment. The slackistrano gem does most of the heavy lifting for you. Its default messages are unobtrusive and can be adjusted easily.
When deploying, it posts to a Slack channel like this:
Integrating Slackistrano with Capistrano 3 is fairly simple.
Geordi 1.0 features a command line application geordi
, that holds most of Geordi's previous commands.
command help and usage examples right within geordi
(geordi help
and geordi help <command>
)
quick command access: type just the first few letters of a command, e.g. geordi rs
or geordi dev[server]
command dependencies, e.g. geordi rspec
invokes geordi bundle-install
(which bundles only if needed)
no cluttered /usr/bin
, but all commands in one handy tool
template for easily adding new...
With this command you can initiate an application restart without touching restart.txt. Unlike touching restart.txt, this tool initiates the restart immediately instead of on the next request. http://blog.phusion.nl/2014/01/02/phusion-passenger-4-0-33-released/
If you want to use this with capistrano 2.x just replace the touch command:
- run "touch #{current_path}/tmp/restart.txt"
+ run "passenger-config restart-app --ignore-app-not-running #{deploy_to}...
Rails has always included a scaffold
script that generates a default controller implementation for you. Unfortunately that generated controller is unnecessarily verbose.
When we take over Rails projects from other teams, we often find that controllers are the unloved child, where annoying glue code has been paved over and over again, negotiating between request and model using implicit and convoluted protocols.
We prefer a different approach. We believe that among all the classes in a Rails project, controllers are some of the hardest to...
Capistrano 2 brings the shell
command which allows you to run commands on your deployment targets.
There is also invoke
to run a command directly from your terminal.
Both commands allow running Capistrano tasks or shell commands, and scope to individual machines or machine roles.
Unfortunately Capistrano 3 does not include these commands any more.
First of all, spawn a Capistrano shell (we're using the multistage
extension here):
$ cap staging shell
In your "cap" shell you can now run Capistrano ta...
If you save your uploads to a made up directory like "RAILS_ROOT/uploads"
, this directory goes away after every deploy (since every release gets a new). Also this directory is not shared between multiple application servers, so your uploads are randomly saved to one local filesystem or another. Fixing this afterwards is a lot of fun.
Only two folders are, by default, shared between our application servers and deployments: "RAILS_ROOT/storage"
and `"RAILS...
This card shows how to upgrade a Rails 2 application from Rails 2.3.8 through every single patch level up to 2.3.18, and then, hopefully, Rails LTS.
This release has many minor changes and fixes to prepare your application for Rails 3.
Step-by-step upgrade instructions:
rails
gemenvironment.rb
so it says RAILS_GEM_VERSION = '2.3.9'
environment.rb
so all invocations ...Our development process makes us deploy very often. As the number of releases grows, junk clogs up the hard drive of our application servers:
tmp
folders with compiled view templates etc.public/assets
directory to shared/assets
. This is cool since we can still serve previous assets after a new release, in the window where browser caches might still have references to old assets. But i...Given you use Capistrano together with bundler to automatically install your gems when deploying.
I recently had the problem that Capistrano stalled like this:
[err :: host.name.tld] Username:
It turned out that I this originated from GitHub. We had a gem in our Gemfile that explicitly pointed to a GitHub URL like that:
gem 'foogem', :git => 'https://github.com/blubb/foogem.git'
The URL was returning a 404 which caused the problems. You have to get another gem or point to a fork on GitHub.
Geordi now has a script that runs capistrano with all known deploy targets (i.e. staging, production...).
Use with
geordi capistrano deploy:migrations
or
geordi capistrano deploy
The abbrevation geordi cap ...
works as well.