capistrano_evrone_recipes 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,92 @@
1
- capistrano_evrone_recipes
2
- =========================
1
+ # Evrone collection of Capistrano recipes
3
2
 
4
- Capistrano recipes used at evrone company
3
+ We deploy a lot of Rails applications and our developers have to solve similar problems each time during the deployment: how to run workers, how to generate crontab, how to precompile assets faster and so on. This collection of recipes helps us to solve them.
4
+
5
+ Recipe use:
6
+
7
+ * [`foreman`][foreman] + [`foreman_export_runitu`][runitu] to generate runit scripts with the Procfile
8
+ * [`whenever`][whenever] to generate crontab
9
+ * [`unicorn`][unicorn] to run the application
10
+
11
+ It also consider that you use *system wide rbenv* on the server.
12
+
13
+ ##Installation
14
+
15
+ gem 'capistrano_evrone_recipes', :require => false
16
+
17
+ Capfile example:
18
+
19
+ require "capistrano_evrone_recipes/capistrano"
20
+
21
+ set :repository, "git@github.com:..."
22
+ set :application, "my_cook_application"
23
+
24
+ task :production do
25
+ role :web, "web.example.com"
26
+ role :app, "app.example.com"
27
+ role :crontab, "app.example.com"
28
+ role, :db, "db.example.com", :primary => true
29
+ role, :worker, "workers.example.com"
30
+ end
31
+
32
+ task :staging do
33
+ server "stage.example.com", :web, :app, :crontab, :db, :worker
34
+ end
35
+
36
+ As you can see, we use use roles to bind the tasks, and there are some additions to roles and additional roles:
37
+
38
+ **web** compiles assets if content of `app/assets` was changed since last deploy (add FORCE=1 to force the assets compilation)
39
+
40
+ **app** all files from `shared/config` is being symlinked to `current/config` like:
41
+
42
+ shared/config/database.yml -> current/config/database.yml
43
+ shared/config/settings/production.yml -> current/config/settings/production.yml
44
+
45
+ **crontab** generates crontab with `whenever` gem, only if the content of `config/schedule.rb` was changed (add FORCE=1 to force the crontab generation)
46
+
47
+ **db** run migrations only if `db/migrate` was changed (add FORCE=1 to force migrations or SKIP_MIGRATION=1 to skip them)
48
+
49
+ **worker** Procfile exports runit configs to `deploy_to/application/services`
50
+
51
+ On **deploy:restart** unicorn and runit workers is being restarted.
52
+
53
+ You can use some extra `cap` tasks:
54
+
55
+ * `rails:console` to launch `rails console` on remote server
56
+ * `rails:dbconsole` to launch `rails dbconsole` on remote server
57
+ * `login` to open SSH session under user `deploy` and switch catalog to Capistrano's `current_path`
58
+
59
+ **Important**
60
+
61
+ To run succesfully together with system wide rbenv, all you tasks in Procfile must be started with `rbenv exec`
62
+
63
+ ##Capistrano
64
+
65
+ Default variables:
66
+
67
+ logger.level = Capistrano::Logger::DEBUG
68
+ default_run_options[:pty] = true
69
+ ssh_options[:forward_agent] = true
70
+ set :bundle_cmd, "rbenv exec bundle"
71
+ set :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec"
72
+ set :rake, -> { "#{bundle_cmd} exec rake" }
73
+ set :keep_releases, 7
74
+ set :scm, "git"
75
+ set :user, "deploy"
76
+ set :deploy_via, :unshared_remote_cache
77
+ set :copy_exclude, [".git"]
78
+ set :repository_cache, -> { "#{deploy_to}/shared/#{application}.git" }
79
+ set :normalize_asset_timestamps, false
80
+
81
+ ##Bonus track
82
+
83
+ To enable silent mode, add `ENV['CAP_SILENT_MODE']` before the `require 'capistrano_evrone_recipes/capistrano'` in your `Capfile`
84
+
85
+ ![silent mode](https://www.evernote.com/shard/s38/sh/4ea45631-93bc-4c03-bad8-f0aa40ca637b/8680b09c40342c6a885212b212b1c746/res/b04ff7c4-b29c-41b2-ab0a-6664cf0b75b9/skitch.png)
86
+
87
+
88
+
89
+ [foreman]: https://github.com/ddollar/foreman
90
+ [runitu]: https://github.com/evrone/foreman_export_runitu
91
+ [whenever]: https://github.com/javan/whenever
92
+ [unicorn]: http://unicorn.bogomips.org/
@@ -3,7 +3,7 @@ module CapistranoEvroneRecipes
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 7
6
+ PATCH = 8
7
7
 
8
8
  def self.to_s
9
9
  "#{MAJOR}.#{MINOR}.#{PATCH}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_evrone_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-21 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano