NYULibraries Deploy offers a set of common rake tasks for the NYU libraries, as well as a set of common capistrano recipes mixed into a delicious default recipe. Most likely the capistrano recipes will handle most of the Rake tasks, but they can be used independently.
Since the NYU Libraries uses the rails_config
gem,
we need a task to explicitly load the relevant settings (e.g. license key, app name) to newrelic.yml in the absence
of a Rails environment.
rake nyu:newrelic:set
rake nyu:newrelic:reset
Start, stop, and restart tasks for the Puma webserver.
rake nyu:puma:start[9292]
rake nyu:puma:restart[9292]
rake nyu:puma:stop[9292]
This provides recipes that allow us to precompile the assets (only if their were changes!) and to create a symlink for the assets.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/assets'
Easy, the asset precompilation will work automatically after the capistrano's deploy:update_code
task, and the
symlinking will work automatically before capistrano's finalize_update
.
If you need, you can always run cap deploy:assets:precompile
or cap deploy:assets:symlink
in a CLI.
All this does is that it loads up
Bundler's capistrano recipe
and hooks deploy:migrate
to run after it.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/bundler'
Clears rail cache!
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/cache'
Or you can run cap cache:tmp_clear
.
Loads up capistrano's multistage. Thats it.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/multistage'
# Same as
require 'capistrano/ext/multistage
Loads up New Relic's capistrano recipes
and adds two new tasks, newrelic:set
and newrelic:reset
.
cap newrelic:set
just runs the rake task defined above,
and cap newrelic:set
runs the reset one. Also hooks New Relic's newrelic:notice_deployment
to run after
deploy:update
.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/new_relic'
This beast makes use of the rails_config
gem and loads the relevant settings
(app name, servers, etc) from capistrano.yml.
rails_config:set_variables
reads from capistrano.yml and sets variables and rails_config:set_servers
sets
the servers that multistage will use to deploy to but you'll only need to worry about rails_config:see
which
prints out the results of the first two rails_config
tasks.
This one is very important for NYULibraries!
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/rails_config'
Loads up rvm's capistrano and hooks
it on to run before deploy
.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/rvm'
Very new idea, trys to find the difference from the last two git tags and sends the difference to a specified
recipient. Run using cap send_diff:send_diff
.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/send_diff'
Tags the deployed app with a prespecified tagging convention.
cap tagging:checkout_branch
will specify the branch to tag and check it out.
cap tagging:deploy
will create the tag and deploy it.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano/tagging'
Since this could work on an app that requires a server, we have some server specific capistrano tasks.
Capistrano recipes to control passenger.
-
cap deploy:start
- Start passenger server. -
cap deploy:stop
- Stop passenger server. -
cap deploy:restart
- Restart passenger server. -
cap deploy:passenger_symlink
- Links passenger to the latest app location.require 'nyulibraries/deploy/capistrano/server/passenger'
Capistrano recipes to control puma. Uses this very gem's rake tasks
-
cap deploy:start
- Start puma server. -
cap deploy:stop
- Stop puma server. -
cap deploy:restart
- Restart puma server.require 'nyulibraries/deploy/capistrano/server/puma'
We've taken the liberty to define a default recipe and default settings. Most of our apps won't need anything past defaults, but if there are small changes you can easily override them.
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano'
This will load the default attributes, with a default recipe that will use all of the above mentioned capistrano recipes with a passenger server. All you have to do is
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano'
set :app_title, "APP_TITLE"
If your app's title is different from the git repo, then you have to also do
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano'
set :app_title, "APP_TITLE"
set :repository, "git@github.com:GITUSER/REPO_NAME.git"
Optionally, you can define who to send the git diff info to by:
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano'
set :app_title, "APP_TITLE"
set :repository, "git@github.com:GITUSER/REPO_NAME.git"
set :recipient, "email" # Has to be email address!
Finally, you can override any one of the defaults, for example overriding branch:
# In your config/deploy.rb
require 'nyulibraries/deploy/capistrano'
set :app_title, "APP_TITLE"
set :repository, "git@github.com:GITUSER/REPO_NAME.git"
set :recipient, "email" # Has to be email address!
set :branch, "cool_branch_doritos"