heroku_san 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/CHANGELOG +15 -1
- data/README.rdoc +17 -12
- data/VERSION +1 -1
- data/heroku_san.gemspec +54 -0
- data/lib/heroku_san/tasks.rb +21 -17
- data/lib/heroku_san.rb +0 -0
- data/lib/tasks/heroku.rake +0 -204
- metadata +6 -4
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1 +1,15 @@
|
|
1
|
-
v0.0
|
1
|
+
v0.2.0
|
2
|
+
============================================
|
3
|
+
|
4
|
+
Elijah Miller
|
5
|
+
Fix newline error in gem manifest
|
6
|
+
Improve instructions
|
7
|
+
|
8
|
+
Glenn Roberts
|
9
|
+
Gem-ify it
|
10
|
+
Improve generation of gems manifest
|
11
|
+
|
12
|
+
|
13
|
+
v0.0.1.
|
14
|
+
============================================
|
15
|
+
Initial release.
|
data/README.rdoc
CHANGED
@@ -29,34 +29,34 @@ In config/heroku.yml you will need add the Heroku apps that you would like to at
|
|
29
29
|
production: awesomeapp
|
30
30
|
staging: awesomeapp-staging
|
31
31
|
demo: awesomeapp-demo
|
32
|
-
|
33
|
-
If this is a fresh project, heroku_san can create all the applications for
|
32
|
+
|
33
|
+
If this is a fresh project, heroku_san can create all the applications for
|
34
34
|
you, and set the RACK_ENV.
|
35
35
|
|
36
36
|
rake all heroku:create heroku:rack_env
|
37
37
|
|
38
38
|
== Usage
|
39
39
|
|
40
|
-
After configuring your Heroku apps you can use rake tasks to control the
|
40
|
+
After configuring your Heroku apps you can use rake tasks to control the
|
41
41
|
apps.
|
42
42
|
|
43
43
|
rake production deploy
|
44
|
-
|
44
|
+
|
45
45
|
A rake task with the shorthand name of each app is now available and adds that
|
46
46
|
server to the list that subsequent commands will execute on. Because this list
|
47
47
|
is additive, you can easily select which servers to run a command on.
|
48
48
|
|
49
49
|
rake demo staging restart
|
50
50
|
|
51
|
-
A special rake task 'all' is created that causes any further commands to
|
51
|
+
A special rake task 'all' is created that causes any further commands to
|
52
52
|
execute on all heroku apps.
|
53
|
-
|
54
|
-
Manipulate collaborators on all this project's apps (prompts for email
|
53
|
+
|
54
|
+
Manipulate collaborators on all this project's apps (prompts for email
|
55
55
|
address):
|
56
|
-
|
57
|
-
rake all heroku:share
|
56
|
+
|
57
|
+
rake all heroku:share
|
58
58
|
rake all heroku:unshare
|
59
|
-
|
59
|
+
|
60
60
|
Need to add remotes for each app?
|
61
61
|
|
62
62
|
rake all heroku:remotes
|
@@ -77,14 +77,19 @@ A full list of tasks provided:
|
|
77
77
|
rake heroku:unshare # Removes a collaborator
|
78
78
|
rake migrate # Migrates and restarts remote servers
|
79
79
|
rake restart # Restarts remote servers
|
80
|
-
|
80
|
+
|
81
81
|
Frequently used tasks are not namespaced, everything else lives under heroku.
|
82
82
|
|
83
|
+
== Links
|
84
|
+
|
85
|
+
Homepage:: http://github.com/fastestforward/heroku_san
|
86
|
+
Bug Tracker:: http://heroku_san.lighthouseapp.com/projects/56301-heroku_san/tickets
|
87
|
+
|
83
88
|
== Contributors
|
84
89
|
|
90
|
+
Elijah Miller (elijah.miller@gmail.com)
|
85
91
|
Glenn Roberts (glenn.roberts@siyelo.com)
|
86
92
|
|
87
93
|
== License
|
88
94
|
|
89
|
-
Homepage:: http://github.com/fastestforward/heroku_san
|
90
95
|
License:: Copyright (c) 2009 Elijah Miller <mailto:elijah.miller@gmail.com>, released under the MIT license.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/heroku_san.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{heroku_san}
|
8
|
+
s.version = "0.2.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Elijah Miller", "Glenn Roberts"]
|
12
|
+
s.date = %q{2010-07-20}
|
13
|
+
s.description = %q{Manage multiple Heroku instances/apps for a single Rails app using Rake}
|
14
|
+
s.email = %q{glenn.roberts@siyelo.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc",
|
18
|
+
"TODO"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".gitignore",
|
22
|
+
"CHANGELOG",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"TODO",
|
27
|
+
"VERSION",
|
28
|
+
"heroku_san.gemspec",
|
29
|
+
"init.rb",
|
30
|
+
"install.rb",
|
31
|
+
"lib/heroku_san.rb",
|
32
|
+
"lib/heroku_san/tasks.rb",
|
33
|
+
"lib/tasks/heroku.rake",
|
34
|
+
"lib/templates/heroku.example.yml",
|
35
|
+
"rails/init.rb",
|
36
|
+
"uninstall.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/glennr/heroku_san}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.7}
|
42
|
+
s.summary = %q{A bunch of useful Rake tasks for managing your Heroku apps}
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
else
|
50
|
+
end
|
51
|
+
else
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/lib/heroku_san/tasks.rb
CHANGED
@@ -21,24 +21,28 @@ task :all do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
namespace :heroku do
|
24
|
+
desc "Creates the Heroku app"
|
25
|
+
task :create do
|
26
|
+
each_heroku_app do |name, app, repo|
|
27
|
+
system_with_echo "heroku create #{app}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
24
31
|
desc "Generate the Heroku gems manifest from gem dependencies"
|
25
32
|
task :gems => 'gems:base' do
|
26
33
|
RAILS_ENV='production'
|
27
34
|
Rake::Task[:environment].invoke
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
list << "rails\n"
|
33
|
-
end
|
34
|
-
list << Rails.configuration.gems.reject{|g| g.frozen? && !g.framework_gem?}.map do |gem|
|
35
|
-
command, *options = gem.send(:install_command)
|
36
|
-
options.join(" ") + "\n"
|
35
|
+
gems = Rails.configuration.gems.reject { |g| g.frozen? && !g.framework_gem? }
|
36
|
+
list = gems.collect do |g|
|
37
|
+
command, *options = g.send(:install_command)
|
38
|
+
options.join(" ")
|
37
39
|
end
|
40
|
+
|
41
|
+
list.unshift(%Q{rails --version "= #{Rails.version}"})
|
42
|
+
|
38
43
|
File.open(File.join(RAILS_ROOT, '.gems'), 'w') do |f|
|
39
|
-
f.write(list)
|
44
|
+
f.write(list.join("\n"))
|
40
45
|
end
|
41
|
-
puts ".gems has been updated with your application's gem dependencies."
|
42
46
|
end
|
43
47
|
|
44
48
|
desc 'Add git remotes for all apps in this project'
|
@@ -102,7 +106,7 @@ namespace :heroku do
|
|
102
106
|
end
|
103
107
|
end
|
104
108
|
|
105
|
-
desc "Deploys, migrates and restarts latest code
|
109
|
+
desc "Deploys, migrates and restarts latest code"
|
106
110
|
task :deploy do
|
107
111
|
each_heroku_app do |name, app, repo|
|
108
112
|
branch = `git branch`.scan(/^\* (.*)\n/).to_s
|
@@ -116,7 +120,7 @@ task :deploy do
|
|
116
120
|
end
|
117
121
|
end
|
118
122
|
|
119
|
-
desc "Force deploys, migrates and restarts latest code
|
123
|
+
desc "Force deploys, migrates and restarts latest code"
|
120
124
|
task :force_deploy do
|
121
125
|
@git_push_arguments ||= []
|
122
126
|
@git_push_arguments << '--force'
|
@@ -130,21 +134,21 @@ task :capture do
|
|
130
134
|
end
|
131
135
|
end
|
132
136
|
|
133
|
-
desc "Opens a remote
|
137
|
+
desc "Opens a remote console"
|
134
138
|
task :console do
|
135
139
|
each_heroku_app do |name, app, repo|
|
136
140
|
system_with_echo "heroku console --app #{app}"
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
140
|
-
desc "Restarts remote
|
144
|
+
desc "Restarts remote servers"
|
141
145
|
task :restart do
|
142
146
|
each_heroku_app do |name, app, repo|
|
143
147
|
system_with_echo "heroku restart --app #{app}"
|
144
148
|
end
|
145
149
|
end
|
146
150
|
|
147
|
-
desc "Migrates and restarts remote
|
151
|
+
desc "Migrates and restarts remote servers"
|
148
152
|
task :migrate do
|
149
153
|
each_heroku_app do |name, app, repo|
|
150
154
|
system_with_echo "heroku rake --app #{app} db:migrate && heroku restart --app #{app}"
|
@@ -195,4 +199,4 @@ def each_heroku_app
|
|
195
199
|
|
196
200
|
exit(1)
|
197
201
|
end
|
198
|
-
end
|
202
|
+
end
|
data/lib/heroku_san.rb
ADDED
File without changes
|
data/lib/tasks/heroku.rake
CHANGED
@@ -1,205 +1 @@
|
|
1
|
-
<<<<<<< HEAD
|
2
|
-
HEROKU_CONFIG_FILE = File.join(RAILS_ROOT, 'config', 'heroku.yml')
|
3
|
-
|
4
|
-
HEROKU_SETTINGS =
|
5
|
-
if File.exists?(HEROKU_CONFIG_FILE)
|
6
|
-
YAML.load_file(HEROKU_CONFIG_FILE)
|
7
|
-
else
|
8
|
-
{}
|
9
|
-
end
|
10
|
-
|
11
|
-
(HEROKU_SETTINGS['apps'] || []).each do |name, app|
|
12
|
-
desc "Select #{name} Heroku app for later commands"
|
13
|
-
task name do
|
14
|
-
@heroku_apps ||= []
|
15
|
-
@heroku_apps << name
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Select all Heroku apps for later command'
|
20
|
-
task :all do
|
21
|
-
@heroku_apps = HEROKU_SETTINGS['apps'].keys
|
22
|
-
end
|
23
|
-
|
24
|
-
namespace :heroku do
|
25
|
-
desc "Creates the Heroku app"
|
26
|
-
task :create do
|
27
|
-
each_heroku_app do |name, app, repo|
|
28
|
-
system_with_echo "heroku create #{app}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
desc "Generate the Heroku gems manifest from gem dependencies"
|
33
|
-
task :gems do
|
34
|
-
RAILS_ENV='production'
|
35
|
-
Rake::Task[:environment].invoke
|
36
|
-
list = Rails.configuration.gems.collect do |g|
|
37
|
-
command, *options = g.send(:install_command)
|
38
|
-
options.join(" ")
|
39
|
-
end
|
40
|
-
|
41
|
-
list.unshift(%Q{rails --version "= #{Rails.version}"})
|
42
|
-
|
43
|
-
File.open(File.join(RAILS_ROOT, '.gems'), 'w') do |f|
|
44
|
-
f.write(list.join("\n"))
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
desc 'Add git remotes for all apps in this project'
|
49
|
-
task :remotes do
|
50
|
-
each_heroku_app do |name, app, repo|
|
51
|
-
system("git remote add #{name} #{repo}")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
desc 'Adds a collaborator'
|
56
|
-
task :share do
|
57
|
-
print "Email address of collaborator to add: "
|
58
|
-
$stdout.flush
|
59
|
-
email = $stdin.gets
|
60
|
-
each_heroku_app do |name, app, repo|
|
61
|
-
system_with_echo "heroku sharing:add --app #{app} #{email}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc 'Adds a collaborator'
|
66
|
-
task :unshare do
|
67
|
-
print "Email address of collaborator to remove: "
|
68
|
-
$stdout.flush
|
69
|
-
email = $stdin.gets
|
70
|
-
each_heroku_app do |name, app, repo|
|
71
|
-
system_with_echo "heroku sharing:remove --app #{app} #{email}"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
desc 'Lists configured apps'
|
76
|
-
task :apps => :all do
|
77
|
-
each_heroku_app do |name, app, repo|
|
78
|
-
puts "#{name} is shorthand for the Heroku app #{app} located at:"
|
79
|
-
puts " #{repo}"
|
80
|
-
puts
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
desc 'Add proper RACK_ENV to each application'
|
85
|
-
task :rack_env => :all do
|
86
|
-
each_heroku_app do |name, app, repo|
|
87
|
-
command = "heroku config --app #{app}"
|
88
|
-
puts command
|
89
|
-
config = Hash[`#{command}`.scan(/^(.+?)\s*=>\s*(.+)$/)]
|
90
|
-
if config['RACK_ENV'] != name
|
91
|
-
system_with_echo "heroku config:add --app #{app} RACK_ENV=#{name}"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
desc 'Creates an example configuration file'
|
97
|
-
task :create_config do
|
98
|
-
example = File.join(File.dirname(__FILE__), '..', 'templates', 'heroku.example.yml')
|
99
|
-
if File.exists?(HEROKU_CONFIG_FILE)
|
100
|
-
puts "config/heroku.yml already exists"
|
101
|
-
else
|
102
|
-
puts "Copied example config to config/heroku.yml"
|
103
|
-
FileUtils.cp(example, HEROKU_CONFIG_FILE)
|
104
|
-
system_with_echo("#{ENV['EDITOR']} #{HEROKU_CONFIG_FILE}")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
desc "Deploys, migrates and restarts latest code"
|
110
|
-
task :deploy do
|
111
|
-
each_heroku_app do |name, app, repo|
|
112
|
-
branch = `git branch`.scan(/^\* (.*)\n/).to_s
|
113
|
-
if branch.present?
|
114
|
-
@git_push_arguments ||= []
|
115
|
-
system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{branch}:master && heroku rake --app #{app} db:migrate && heroku restart --app #{app}"
|
116
|
-
else
|
117
|
-
puts "Unable to determine the current git branch, please checkout the branch you'd like to deploy"
|
118
|
-
exit(1)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
desc "Force deploys, migrates and restarts latest code"
|
124
|
-
task :force_deploy do
|
125
|
-
@git_push_arguments ||= []
|
126
|
-
@git_push_arguments << '--force'
|
127
|
-
Rake::Task[:deploy].execute
|
128
|
-
end
|
129
|
-
|
130
|
-
desc "Captures a bundle on Heroku"
|
131
|
-
task :capture do
|
132
|
-
each_heroku_app do |name, app, repo|
|
133
|
-
system_with_echo "heroku bundles:capture --app #{app}"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
desc "Opens a remote console"
|
138
|
-
task :console do
|
139
|
-
each_heroku_app do |name, app, repo|
|
140
|
-
system_with_echo "heroku console --app #{app}"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
desc "Restarts remote servers"
|
145
|
-
task :restart do
|
146
|
-
each_heroku_app do |name, app, repo|
|
147
|
-
system_with_echo "heroku restart --app #{app}"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
desc "Migrates and restarts remote servers"
|
152
|
-
task :migrate do
|
153
|
-
each_heroku_app do |name, app, repo|
|
154
|
-
system_with_echo "heroku rake --app #{app} db:migrate && heroku restart --app #{app}"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
namespace :db do
|
159
|
-
task :pull do
|
160
|
-
each_heroku_app do |name, app, repo|
|
161
|
-
system_with_echo "heroku pgdumps:capture --app #{app}"
|
162
|
-
dump = `heroku pgdumps --app #{app}`.split("\n").last.split(" ").first
|
163
|
-
system_with_echo "mkdir -p #{RAILS_ROOT}/db/dumps"
|
164
|
-
file = "#{RAILS_ROOT}/db/dumps/#{dump}.sql.gz"
|
165
|
-
url = `heroku pgdumps:url --app #{app} #{dump}`.chomp
|
166
|
-
system_with_echo "wget", url, "-O", file
|
167
|
-
system_with_echo "rake db:drop db:create"
|
168
|
-
system_with_echo "gunzip -c #{file} | #{RAILS_ROOT}/script/dbconsole"
|
169
|
-
system_with_echo "rake jobs:clear"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def system_with_echo(*args)
|
175
|
-
puts args.join(' ')
|
176
|
-
system(*args)
|
177
|
-
end
|
178
|
-
|
179
|
-
def each_heroku_app
|
180
|
-
if @heroku_apps.blank? && HEROKU_SETTINGS['apps'].size == 1
|
181
|
-
app = HEROKU_SETTINGS['apps'].keys.first
|
182
|
-
puts "Defaulting to #{app} app since only one app is defined"
|
183
|
-
@heroku_apps = [app]
|
184
|
-
end
|
185
|
-
if @heroku_apps.present?
|
186
|
-
@heroku_apps.each do |name|
|
187
|
-
app = HEROKU_SETTINGS['apps'][name]
|
188
|
-
yield(name, app, "git@heroku.com:#{app}.git")
|
189
|
-
end
|
190
|
-
puts
|
191
|
-
else
|
192
|
-
puts "You must first specify at least one Heroku app:
|
193
|
-
rake <app> [<app>] <command>
|
194
|
-
rake production restart
|
195
|
-
rake demo staging deploy"
|
196
|
-
|
197
|
-
puts "\nYou can use also command all Heroku apps for this project:
|
198
|
-
rake all heroku:share"
|
199
|
-
|
200
|
-
exit(1)
|
201
|
-
end
|
202
|
-
end
|
203
|
-
=======
|
204
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'heroku_san', 'tasks'))
|
205
|
-
>>>>>>> glennr/lib_task
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_san
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Elijah Miller
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-20 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -38,8 +38,10 @@ files:
|
|
38
38
|
- Rakefile
|
39
39
|
- TODO
|
40
40
|
- VERSION
|
41
|
+
- heroku_san.gemspec
|
41
42
|
- init.rb
|
42
43
|
- install.rb
|
44
|
+
- lib/heroku_san.rb
|
43
45
|
- lib/heroku_san/tasks.rb
|
44
46
|
- lib/tasks/heroku.rake
|
45
47
|
- lib/templates/heroku.example.yml
|