easy-deployment 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +76 -0
- data/README.md +26 -1
- data/easy-deployment.gemspec +1 -3
- data/lib/easy-deployment.rb +2 -0
- data/lib/easy-deployment/version.rb +1 -1
- data/lib/easy/deployment/backup.rb +0 -6
- data/lib/easy/deployment/capistrano.rb +10 -1
- data/lib/easy/deployment/whenever.rb +1 -1
- data/lib/easy/generators/backup_generator.rb +46 -0
- data/lib/easy/generators/deployment_generator.rb +38 -33
- data/lib/easy/generators/generator_helpers.rb +15 -0
- data/lib/easy/generators/stage_generator.rb +3 -2
- data/lib/easy/generators/templates/backup.rb.tt +58 -0
- data/lib/easy/generators/templates/deploy.rb.tt +36 -8
- data/lib/easy/generators/templates/s3.yml +5 -0
- data/lib/easy/generators/templates/schedule.rb.tt +36 -0
- data/lib/easy/generators/templates/stage.rb.tt +2 -4
- data/lib/easy/generators/templates/stage/{apache/%application_name%.tt → apache.conf.tt} +1 -1
- data/lib/easy/generators/templates/stage/logrotate.conf.tt +8 -0
- metadata +15 -48
- data/ChangeLog +0 -25
- data/lib/easy/generators/logrotate_generator.rb +0 -21
data/CHANGELOG.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Changelog for easy-deployment
|
2
|
+
|
3
|
+
## 0.5.0 (unreleased)
|
4
|
+
|
5
|
+
Large rewrite of both templates, and generator code.
|
6
|
+
|
7
|
+
Major new feature is generation of backup config using the gems `whenever` and `backup`
|
8
|
+
|
9
|
+
Enhancements:
|
10
|
+
|
11
|
+
* Now fixed to capistrano 2.13.5 - dependencies on external capistrano-ext and capistrano_colors are removed.
|
12
|
+
* Added annotation task to write branch name, git revision, time of deploy, and user to the application root as version.txt
|
13
|
+
* Removed messy optparse code, and let Thor handle option parsing
|
14
|
+
* `deploy.rb` template now displays all feature modules, with some optional ones commented out
|
15
|
+
* `deploy.rb` template is now updated with current deployment practices (including newrelic and bugsnag services)
|
16
|
+
* Added generator to create backup configuration - for scheduling cron jobs to backup application data to S3
|
17
|
+
|
18
|
+
Bug Fixes:
|
19
|
+
|
20
|
+
* `deploy.rb` and `staging.rb` etc files are rendered correctly as templates, instead of copied over without rendering
|
21
|
+
* use `deploy:create_symlink` instead of deprecated `deploy:symlink`
|
22
|
+
|
23
|
+
## 0.4.4 - 2013-01-11
|
24
|
+
|
25
|
+
Bug Fixes:
|
26
|
+
|
27
|
+
* Bugfix for previous niet role definition, variable should be delayed being evaluated
|
28
|
+
|
29
|
+
## 0.4.3 - 2013-01-10
|
30
|
+
|
31
|
+
Enhancements:
|
32
|
+
|
33
|
+
* the server role for the niet tasks are now configurable via `set :niet_roles, [:job]`
|
34
|
+
|
35
|
+
## 0.4.2 - 2013-01-09
|
36
|
+
|
37
|
+
Enhancements:
|
38
|
+
|
39
|
+
* path to the binary apachectl command is now able to be configured via `set :apachectl_bin`
|
40
|
+
* Added documentation to README.md for several of the optional features
|
41
|
+
|
42
|
+
## 0.4.1 - 2012-12-10
|
43
|
+
|
44
|
+
Bug Fixes:
|
45
|
+
|
46
|
+
* raise exception if `cap niet:start` is run without `cap niet:setup` being run first
|
47
|
+
|
48
|
+
## 0.4.0 - 2012-11-19
|
49
|
+
|
50
|
+
Enhancements:
|
51
|
+
|
52
|
+
* include capistrano_colors by default
|
53
|
+
* apache:configure task now copies a folder stage/apache/* if present falling back to previous state/apache.conf
|
54
|
+
* added `easy/deployment/performance` optional require to track the times of deployments
|
55
|
+
|
56
|
+
## 0.3.3 - 2012-10-16
|
57
|
+
|
58
|
+
Bug Fixes
|
59
|
+
|
60
|
+
* `deploy:reference` should use the rails_env, not the stage
|
61
|
+
|
62
|
+
## 0.3.0 - 2012-09-04
|
63
|
+
|
64
|
+
Enhancements:
|
65
|
+
|
66
|
+
* Add `apache:configure_and_reload` capistrano task, which will configure the site, test the configuration & gracefully reload the Apache configuration
|
67
|
+
|
68
|
+
## 0.2.2 - 2012-08-27
|
69
|
+
|
70
|
+
Enhancements:
|
71
|
+
|
72
|
+
* Add `apache:configtest` capistrano task
|
73
|
+
|
74
|
+
Bug Fixes:
|
75
|
+
|
76
|
+
* Spelling corrections
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Easy::Deployment
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/easy-deployment)
|
4
|
+
[](https://gemnasium.com/AbleTech/easy-deployment)
|
5
|
+
[](https://codeclimate.com/github/AbleTech/easy-deployment)
|
6
|
+
|
3
7
|
This gem is for encapsulating Abletech's common deployment patterns using capistrano.
|
4
8
|
|
5
9
|
## Installation
|
@@ -22,6 +26,9 @@ Run:
|
|
22
26
|
|
23
27
|
$ rails g easy:deployment
|
24
28
|
|
29
|
+
The templated configuration files leave several lines blank for you to fill in with TODO placeholders, so it's a good idea to run `rake notes:todo` after installation to see if you've missed any.
|
30
|
+
Replace any missing configuration lines, and don't forget to remove the TODO text/comments
|
31
|
+
|
25
32
|
## Integration
|
26
33
|
|
27
34
|
### Apache
|
@@ -41,7 +48,11 @@ If necessary, you can set the path to the apache2ctl binary via:
|
|
41
48
|
|
42
49
|
set :apachectl_bin, "/usr/sbin/apachectl"
|
43
50
|
|
44
|
-
This assumes your deploy user has access to run the apachectl command with sudo privileges
|
51
|
+
This assumes your deploy user has access to run the apachectl command with sudo privileges. As a recommended security practice, your deploy user should not have general sudo access, instead configure limited sudo access for specific commands only, declaring the full binary path
|
52
|
+
|
53
|
+
# Example sudoers file entries to grant deploy user passwordless sudo privileges to only these commands
|
54
|
+
deploy ALL=(ALL) NOPASSWD:/usr/sbin/apachectl graceful
|
55
|
+
deploy ALL=(ALL) NOPASSWD:/usr/sbin/apachectl configtest
|
45
56
|
|
46
57
|
### Logrotate
|
47
58
|
|
@@ -52,6 +63,20 @@ If you have logrotate installed and /etc/logrotate.d is writable by your deploy
|
|
52
63
|
|
53
64
|
within your deploy.rb to have a logrotate config automatically written
|
54
65
|
|
66
|
+
### Backup
|
67
|
+
|
68
|
+
This includes a generator to create a backup configuration (generator may be disabled when running easy:deployment by passing `--disable-backup`, or run by itself as `rails generate easy:backup`)
|
69
|
+
|
70
|
+
This will generate:
|
71
|
+
|
72
|
+
config/backup.rb
|
73
|
+
config/schedule.rb
|
74
|
+
config/s3.yml
|
75
|
+
|
76
|
+
The created backup configuration will be scheduled on deploy to run nightly via the whenever integration below, and with a backup configuration at `config/backup.rb`
|
77
|
+
The default setup is to backup the capistrano system folder, the configured database, to store the backup in S3, and notify of failures via email.
|
78
|
+
All these settings are configurable, to read more see the documentation for the backup gem https://github.com/meskyanichi/backup and setup your configuration to suit yourself.
|
79
|
+
|
55
80
|
### Whenever
|
56
81
|
|
57
82
|
If you use the whenever gem to manage application crontabs, automatically include the capistrano
|
data/easy-deployment.gemspec
CHANGED
@@ -16,9 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Easy::Deployment::VERSION
|
17
17
|
|
18
18
|
gem.add_runtime_dependency 'rails', '>= 3.0.0'
|
19
|
-
gem.add_runtime_dependency 'capistrano'
|
20
|
-
gem.add_runtime_dependency 'capistrano-ext'
|
21
|
-
gem.add_runtime_dependency 'capistrano_colors'
|
19
|
+
gem.add_runtime_dependency 'capistrano', '~> 2.13.5'
|
22
20
|
|
23
21
|
gem.add_development_dependency 'bundler'
|
24
22
|
gem.add_development_dependency 'rspec', '~> 2.0'
|
data/lib/easy-deployment.rb
CHANGED
@@ -6,14 +6,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
6
6
|
task :setup, :except => { :no_release => true } do
|
7
7
|
run "mkdir -p #{shared_path}/backup/data"
|
8
8
|
end
|
9
|
-
|
10
|
-
desc "Adds a symbolic link from the s3.yml file in the shared/backup into the current/config folder"
|
11
|
-
task :symlink_s3_config do
|
12
|
-
run "ln -sf #{shared_path}/backup/s3.yml #{current_path}/config/s3.yml"
|
13
|
-
end
|
14
9
|
end
|
15
10
|
end
|
16
11
|
|
17
12
|
after 'deploy:setup', 'easy:backup:setup'
|
18
|
-
after 'deploy:symlink', 'easy:backup:symlink_s3_config'
|
19
13
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# To load this capistrano configuraiton, require 'easy/deployment/capistrano' from deploy.rb
|
3
3
|
|
4
4
|
Capistrano::Configuration.instance(:must_exist).load do
|
5
|
-
require 'capistrano_colors'
|
6
5
|
|
7
6
|
# color the string
|
8
7
|
def red(str)
|
@@ -72,4 +71,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
72
71
|
system "git push origin #{branch}:releases/#{stage}"
|
73
72
|
end
|
74
73
|
|
74
|
+
desc "Annotate release into version.txt"
|
75
|
+
task :annotate_release do
|
76
|
+
git_revision = `git rev-parse #{branch} 2> /dev/null`.strip
|
77
|
+
version_info = "Branch/Tag: #{branch}\\nRevision: #{git_revision}\\nDeployed To: #{stage}\\n\\nDeployed At: #{Time.now}\\nBy: #{`whoami`.chomp}\\n"
|
78
|
+
run %Q(printf "#{version_info}" > #{release_path}/version.txt)
|
79
|
+
end
|
80
|
+
|
81
|
+
after "deploy:update", "tag_release"
|
82
|
+
after "deploy:update", "annotate_release"
|
83
|
+
|
75
84
|
end
|
@@ -17,6 +17,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
after "deploy:update_code", "easy:whenever:clear_crontab"
|
20
|
-
after "deploy:
|
20
|
+
after "deploy:create_symlink", "easy:whenever:update_crontab"
|
21
21
|
after "deploy:rollback", "easy:whenever:update_crontab"
|
22
22
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Easy
|
4
|
+
class BackupGenerator < Rails::Generators::Base
|
5
|
+
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from
|
6
|
+
|
7
|
+
include GeneratorHelpers
|
8
|
+
|
9
|
+
desc %{Generates a backup config set to run nightly and upload to S3}
|
10
|
+
|
11
|
+
def create_backup_files
|
12
|
+
gem_group(:backup) do
|
13
|
+
gem "whenever", :require => false
|
14
|
+
case Rails::VERSION::MAJOR
|
15
|
+
when 3
|
16
|
+
gem "backup", "~> 3.0.27", :require => false
|
17
|
+
gem "fog", "~> 1.4.0", :require => false
|
18
|
+
gem "mail", "~> 2.4.0", :require => false
|
19
|
+
when 4
|
20
|
+
gem "backup", "~> 3.1.3", :require => false
|
21
|
+
gem "fog", "~> 1.9.0", :require => false
|
22
|
+
gem "net-ssh", "<= 2.5.2", :require => false # Greater than >= 2.3.0 as well, though we can't express that
|
23
|
+
gem "net-scp", "<= 1.0.4", :require => false # Greater than 1.0.0
|
24
|
+
gem "excon", "~> 0.17.0", :require => false
|
25
|
+
gem "mail", "~> 2.5.0", :require => false
|
26
|
+
else
|
27
|
+
warn "Unsupported rails release detected. You'll need to manage your own dependencies for the backup gem"
|
28
|
+
gem "backup", :require => false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
template("backup.rb.tt", "config/backup.rb")
|
33
|
+
template("schedule.rb.tt", "config/schedule.rb")
|
34
|
+
copy_file("s3.yml", "config/s3.yml")
|
35
|
+
|
36
|
+
run("bundle install")
|
37
|
+
|
38
|
+
say("Backup configuration generated", :green)
|
39
|
+
say(" - TODO: edit config/backup.rb setting notification addresses and other configuration options", :green)
|
40
|
+
say(" - TODO: ensure your S3 keys are set in config/s3.yml", :green)
|
41
|
+
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -1,56 +1,61 @@
|
|
1
1
|
require 'rails/generators'
|
2
|
-
require 'optparse'
|
3
2
|
|
4
3
|
module Easy
|
5
4
|
class DeploymentGenerator < Rails::Generators::Base
|
6
5
|
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
include GeneratorHelpers
|
8
|
+
|
9
|
+
INSTALL_MSG = %{
|
10
|
+
Easy Deployment Config now setup!
|
11
|
+
|
12
|
+
TODO:
|
13
|
+
* Set the correct git repository in config/deploy.rb
|
14
|
+
* Edit Capfile and enable asset pipeline compilation if you are using it (uncomment load 'deploy/assets')
|
15
|
+
}
|
11
16
|
|
12
17
|
desc %{Generates standard able technology deployment script using capistrano}
|
13
18
|
|
14
|
-
|
15
|
-
|
19
|
+
class_option :stages, :type => :array, :default => ['staging', 'production'], :aliases => :s
|
20
|
+
class_option :disable_backup, :type => :boolean, :default => false
|
21
|
+
class_option :disable_bugsnag, :type => :boolean, :default => false
|
22
|
+
class_option :disable_newrelic, :type => :boolean, :default => false
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
def create_deployment_files
|
25
|
+
template("deploy.rb.tt", "config/deploy.rb") # Generate deploy.rb first to use ours not capistrano's deploy.rb
|
19
26
|
capify!
|
20
|
-
remove_file("config/deploy.rb") unless deploy_file_already_existed # Removing this means we aren't prompted to overwrite if we only have the default capistrano deploy.rb
|
21
|
-
# Write our default deploy.rb
|
22
|
-
copy_file("deploy.rb.tt", "config/deploy.rb")
|
23
27
|
|
24
28
|
# Generate all stages specified
|
25
|
-
options[:stages] ||= %w(staging production)
|
26
29
|
options[:stages].each do |stage|
|
27
30
|
generate("easy:stage", stage)
|
28
31
|
end
|
29
32
|
|
30
|
-
|
31
|
-
Easy Deployment Config now setup!
|
32
|
-
|
33
|
-
TODO:
|
34
|
-
* Set the correct git repository in config/deploy.rb
|
35
|
-
}
|
33
|
+
say(INSTALL_MSG, :green)
|
36
34
|
options[:stages].each do |stage|
|
37
|
-
|
35
|
+
say(" * Set the ip address for staging in config/deploy/#{stage}.rb && the apache config in config/deploy/#{stage}/apache.conf", :green)
|
38
36
|
end
|
39
|
-
puts info
|
40
|
-
true
|
41
|
-
end
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
38
|
+
needs_bundle = false
|
39
|
+
|
40
|
+
unless options[:disable_newrelic]
|
41
|
+
say_status(:configure, "New Relic gem")
|
42
|
+
gem("newrelic_rpm", ">= 3.5.3.25")
|
43
|
+
needs_bundle = true
|
44
|
+
end
|
45
|
+
unless options[:disable_bugsnag]
|
46
|
+
say_status(:configure, "bugsnag")
|
47
|
+
gem("bugsnag")
|
48
|
+
needs_bundle = true
|
49
|
+
end
|
50
|
+
|
51
|
+
unless options[:disable_backup]
|
52
|
+
generate("easy:backup")
|
53
|
+
needs_bundle = false # because easy:backup runs bundle install
|
54
|
+
end
|
55
|
+
|
56
|
+
bundle_command(:install) if needs_bundle
|
57
|
+
|
58
|
+
true
|
54
59
|
end
|
55
60
|
|
56
61
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GeneratorHelpers
|
2
|
+
|
3
|
+
def application_name
|
4
|
+
Rails.application.class.name.split("::").first.underscore # surely there's a better way than this
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def bundle_command(command)
|
10
|
+
# say_status :run, "bundle #{command}"
|
11
|
+
# print `"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}`
|
12
|
+
run("bundle #{command}")
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -8,13 +8,14 @@ module Easy
|
|
8
8
|
|
9
9
|
def generate_stage
|
10
10
|
directory("stage", "config/deploy/#{name}")
|
11
|
-
|
11
|
+
template("stage.rb.tt", "config/deploy/#{name}.rb")
|
12
|
+
template("stage/apache.conf.tt", "config/deploy/#{name}/apache.conf")
|
12
13
|
|
13
14
|
# Ensure we have a config/environments/<env-name>.rb
|
14
15
|
dest = "config/environments/#{name}.rb"
|
15
16
|
in_root do
|
16
17
|
unless File.exist?(dest)
|
17
|
-
run("cp config/environments/
|
18
|
+
run("cp config/environments/staging.rb #{dest}")
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Backup::Model.new("<%= application_name %>", "Remote Backup") do
|
2
|
+
|
3
|
+
# This is the rails root location, given this file is located at in Rails.root/config/backup.rb
|
4
|
+
rails_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
5
|
+
|
6
|
+
<%
|
7
|
+
database_engine = "'TODO: FILL IN'"
|
8
|
+
database_config_filename = "database.yml"
|
9
|
+
if defined?(PG)
|
10
|
+
database_engine = 'PostgreSQL'
|
11
|
+
elsif defined?(Mongo)
|
12
|
+
database_engine = 'MongoDB'
|
13
|
+
database_config_filename = "mongo.yml"
|
14
|
+
end
|
15
|
+
%>
|
16
|
+
database_config = YAML.load_file(File.join(rails_root, "config/<%= database_config_filename %>"))
|
17
|
+
|
18
|
+
database <%= database_engine %> do |db|
|
19
|
+
db.name = database_config["database"]
|
20
|
+
db.host = database_config["host"] if database_config["host"]
|
21
|
+
db.port = database_config["port"] if database_config["port"]
|
22
|
+
db.username = database_config["username"] if database_config["username"]
|
23
|
+
db.password = database_config["password"] if database_config["password"]
|
24
|
+
db.additional_options = []
|
25
|
+
end
|
26
|
+
|
27
|
+
archive :system_folder_backup do |archive|
|
28
|
+
# add folders (including sub-folders)
|
29
|
+
folder = File.expand_path("#{rails_root}/../shared/system/")
|
30
|
+
archive.add(folder)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
s3config = YAML.load_file(File.join(rails_root, "config/s3.yml"))
|
35
|
+
|
36
|
+
store_with S3 do |s3|
|
37
|
+
s3.access_key_id = s3config['access_key_id']
|
38
|
+
s3.secret_access_key = s3config['secret_access_key']
|
39
|
+
s3.region = s3config['region']
|
40
|
+
s3.bucket = s3config['backup_bucket']
|
41
|
+
s3.path = "/<%= application_name %>/#{ENV['RAILS_ENV']}/"
|
42
|
+
# s3.keep = 30 # Enable this if you have read/delete access on S3 to clean up old backups
|
43
|
+
end
|
44
|
+
|
45
|
+
compress_with Bzip2 do |compression|
|
46
|
+
compression.level = 9
|
47
|
+
end
|
48
|
+
|
49
|
+
notify_by Mail do |mail|
|
50
|
+
mail.on_success = false
|
51
|
+
mail.on_warning = true
|
52
|
+
mail.on_failure = true
|
53
|
+
|
54
|
+
mail.delivery_method = :sendmail
|
55
|
+
mail.from = 'TODO: set from address'
|
56
|
+
mail.to = 'TODO: set delivery address'
|
57
|
+
end
|
58
|
+
end
|
@@ -1,24 +1,52 @@
|
|
1
|
-
require "capistrano/ext/multistage"
|
2
|
-
require "capistrano_colors"
|
3
|
-
require "bundler/capistrano"
|
4
1
|
begin
|
2
|
+
require "capistrano/ext/multistage"
|
3
|
+
require "bundler/capistrano"
|
5
4
|
require "easy/deployment/capistrano"
|
6
|
-
rescue LoadError
|
7
|
-
$stderr.puts "couldn't load
|
5
|
+
rescue LoadError => e
|
6
|
+
$stderr.puts "couldn't load deployment gems, try `bundle install` and running again with `bundle exec cap <stage> deploy`"
|
7
|
+
$stderr.puts e.message
|
8
8
|
exit(1)
|
9
9
|
end
|
10
10
|
|
11
|
+
# Deployment tools
|
12
|
+
<% unless options[:disable_bugsnag] %>require "bugsnag/capistrano"<% end %>
|
13
|
+
<% unless options[:disable_newrelic] %>require "new_relic/recipes"
|
14
|
+
after "deploy:update", "newrelic:notice_deployment"
|
15
|
+
<% end %><% unless options[:disable_backup] %># Backup
|
16
|
+
require "easy/deployment/backup"
|
17
|
+
require "whenever/capistrano"
|
18
|
+
set :whenever_command, "#{fetch(:bundle_cmd, "bundle")} exec whenever"
|
19
|
+
<% end %>
|
20
|
+
|
11
21
|
set :stages, %w(staging production)
|
12
22
|
set :default_stage, "staging"
|
13
23
|
|
14
|
-
set :application, "<%= application_name %>"
|
24
|
+
set :application, "<%= application_name %>"
|
15
25
|
set :deploy_to, "/var/apps/#{application}"
|
16
26
|
|
17
|
-
# TODO: fill in git repo
|
18
|
-
# set :repository, "git@github.com:AbleTech/easy-deployment.git"
|
27
|
+
# set :repository, "git@github.com:AbleTech/easy-deployment.git" # TODO: fill in git repo
|
19
28
|
set :scm, :git
|
20
29
|
set :deploy_via, :remote_cache
|
21
30
|
set :git_shallow_clone, 1
|
31
|
+
# easy-deployment sets the branch to deploy to the current local branch by default.
|
32
|
+
|
33
|
+
set :bundle_without, defer { fetch(:stages) - [fetch(:stage)] } # Bundle without other stage environments
|
34
|
+
|
35
|
+
set :user, "deploy"
|
36
|
+
set :runner, "deploy"
|
37
|
+
|
38
|
+
# Optional feature: apache restarts
|
39
|
+
# require "easy/deployment/apache"
|
40
|
+
# set :apachectl_bin, "/usr/sbin/apachectl"
|
41
|
+
|
42
|
+
# Optional feature: configure log rotation
|
43
|
+
# require "easy/deployment/logrotate"
|
44
|
+
|
45
|
+
# Optional feature: db reference data. Requires easy-reference gem
|
46
|
+
# require "easy/deployment/dbreference"
|
47
|
+
|
48
|
+
# Optional feature: capistrano performance report. Timings for slow deploys
|
49
|
+
# require "easy/deployment/performance"
|
22
50
|
|
23
51
|
|
24
52
|
# If deploying with RVM:
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Use this file to easily define all of your cron jobs.
|
2
|
+
#
|
3
|
+
# It's helpful, but not entirely necessary to understand cron before proceeding.
|
4
|
+
# http://en.wikipedia.org/wiki/Cron
|
5
|
+
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# set :output, "/path/to/my/cron_log.log"
|
9
|
+
#
|
10
|
+
# every 2.hours do
|
11
|
+
# command "/usr/bin/some_great_command"
|
12
|
+
# runner "MyModel.some_method"
|
13
|
+
# rake "some:great:rake:task"
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# every 4.days do
|
17
|
+
# runner "AnotherModel.prune_old_records"
|
18
|
+
# end
|
19
|
+
|
20
|
+
# Learn more: http://github.com/javan/whenever
|
21
|
+
|
22
|
+
set :output, "log/cron.log"
|
23
|
+
|
24
|
+
|
25
|
+
set :application, "<%= application_name %>"
|
26
|
+
set :base_path, "/var/apps/#{application}"
|
27
|
+
set :current_path, "#{base_path}/current"
|
28
|
+
set :shared_path, "#{base_path}/shared"
|
29
|
+
|
30
|
+
set :output, "#{shared_path}/log/cron.log"
|
31
|
+
set :bundle_cmd, "bundle"
|
32
|
+
|
33
|
+
# Note: doublecheck timezone of your destination server
|
34
|
+
every 1.day, :at => '3:00 am' do
|
35
|
+
command "cd #{current_path} && RAILS_ENV=#{environment} #{bundle_cmd} exec backup perform --trigger #{application} --config-file #{current_path}/config/backup.rb --data-path #{shared_path}/backup/data"
|
36
|
+
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# role :db, "<<%= name %>-ip-address>", :primary => true # This is where Rails migrations will run
|
1
|
+
server '<<%= name %>-ip-address>', :web, :app, :db, :primary => true
|
2
|
+
# :db, :primary => true is where migrations will run.
|
4
3
|
|
5
|
-
set :branch, "master"
|
6
4
|
set :rails_env, "<%= name %>"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -35,49 +35,17 @@ dependencies:
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
none: false
|
37
37
|
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
type: :runtime
|
42
|
-
prerelease: false
|
43
|
-
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
|
-
requirements:
|
46
|
-
- - ! '>='
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: capistrano-ext
|
51
|
-
requirement: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
|
-
requirements:
|
54
|
-
- - ! '>='
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '0'
|
57
|
-
type: :runtime
|
58
|
-
prerelease: false
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
|
-
requirements:
|
62
|
-
- - ! '>='
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '0'
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: capistrano_colors
|
67
|
-
requirement: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
|
-
requirements:
|
70
|
-
- - ! '>='
|
38
|
+
- - ~>
|
71
39
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
40
|
+
version: 2.13.5
|
73
41
|
type: :runtime
|
74
42
|
prerelease: false
|
75
43
|
version_requirements: !ruby/object:Gem::Requirement
|
76
44
|
none: false
|
77
45
|
requirements:
|
78
|
-
- -
|
46
|
+
- - ~>
|
79
47
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
48
|
+
version: 2.13.5
|
81
49
|
- !ruby/object:Gem::Dependency
|
82
50
|
name: bundler
|
83
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +90,7 @@ extra_rdoc_files: []
|
|
122
90
|
files:
|
123
91
|
- .gitignore
|
124
92
|
- .rspec
|
125
|
-
-
|
93
|
+
- CHANGELOG.md
|
126
94
|
- Gemfile
|
127
95
|
- LICENSE
|
128
96
|
- README.md
|
@@ -139,12 +107,17 @@ files:
|
|
139
107
|
- lib/easy/deployment/niet.rb
|
140
108
|
- lib/easy/deployment/performance.rb
|
141
109
|
- lib/easy/deployment/whenever.rb
|
110
|
+
- lib/easy/generators/backup_generator.rb
|
142
111
|
- lib/easy/generators/deployment_generator.rb
|
143
|
-
- lib/easy/generators/
|
112
|
+
- lib/easy/generators/generator_helpers.rb
|
144
113
|
- lib/easy/generators/stage_generator.rb
|
114
|
+
- lib/easy/generators/templates/backup.rb.tt
|
145
115
|
- lib/easy/generators/templates/deploy.rb.tt
|
116
|
+
- lib/easy/generators/templates/s3.yml
|
117
|
+
- lib/easy/generators/templates/schedule.rb.tt
|
146
118
|
- lib/easy/generators/templates/stage.rb.tt
|
147
|
-
- lib/easy/generators/templates/stage/apache
|
119
|
+
- lib/easy/generators/templates/stage/apache.conf.tt
|
120
|
+
- lib/easy/generators/templates/stage/logrotate.conf.tt
|
148
121
|
- spec/easy_deployment_spec.rb
|
149
122
|
- spec/spec_helper.rb
|
150
123
|
homepage: https://github.com/AbleTech/easy-deployment
|
@@ -159,21 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
132
|
- - ! '>='
|
160
133
|
- !ruby/object:Gem::Version
|
161
134
|
version: '0'
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
hash: -2565784837031824026
|
165
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
136
|
none: false
|
167
137
|
requirements:
|
168
138
|
- - ! '>='
|
169
139
|
- !ruby/object:Gem::Version
|
170
140
|
version: '0'
|
171
|
-
segments:
|
172
|
-
- 0
|
173
|
-
hash: -2565784837031824026
|
174
141
|
requirements: []
|
175
142
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.8.
|
143
|
+
rubygems_version: 1.8.23
|
177
144
|
signing_key:
|
178
145
|
specification_version: 3
|
179
146
|
summary: Gem for encapsulating Abletech's deployment practices
|
data/ChangeLog
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
0.3.3 - 2012-10-16
|
2
|
-
|
3
|
-
Bug Fixes
|
4
|
-
|
5
|
-
* deploy:reference should use the rails_env, not the stage
|
6
|
-
|
7
|
-
0.3.0 - 2012-09-04
|
8
|
-
|
9
|
-
Enhancements:
|
10
|
-
|
11
|
-
* Add apache:configure_and_reload capistrano task, which will configure the site, test the configuration & gracefully reload the Apache configuration
|
12
|
-
|
13
|
-
cap apache:configure_and_reload
|
14
|
-
|
15
|
-
0.2.2 - 2012-08-27
|
16
|
-
|
17
|
-
Enhancements:
|
18
|
-
|
19
|
-
* Add apache:configtest capistrano task
|
20
|
-
|
21
|
-
cap apache:configtest
|
22
|
-
|
23
|
-
Bug Fixes:
|
24
|
-
|
25
|
-
* Spelling corrections
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Easy
|
4
|
-
class LogrotateGenerator < Rails::Generators::NamedBase
|
5
|
-
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from
|
6
|
-
|
7
|
-
desc %{Generate a new logrotate.conf file for the given environment name\ne.g. rails g easy:logrotate workshop}
|
8
|
-
|
9
|
-
def generate_stage
|
10
|
-
# directory("stage", "config/#{name}")
|
11
|
-
|
12
|
-
# Ensure we have a config/deploy/<env-name>/logrotate.rb
|
13
|
-
# dest = "config/deploy/#{name}/logrotate.conf"
|
14
|
-
# in_root do
|
15
|
-
# unless File.exist?(dest)
|
16
|
-
# run("cp config/environments/production.rb #{dest}")
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|