fezzik 0.6.0 → 0.6.1
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/README.md +22 -0
- data/fezzik.gemspec +1 -1
- data/lib/fezzik.rb +6 -5
- data/lib/fezzik/dsl.rb +15 -0
- data/lib/fezzik/version.rb +1 -1
- metadata +9 -11
- data/TODO.md +0 -14
- data/bin/fezify +0 -156
data/README.md
CHANGED
@@ -183,6 +183,28 @@ task :print_destination
|
|
183
183
|
end
|
184
184
|
```
|
185
185
|
|
186
|
+
|
187
|
+
## DSL
|
188
|
+
|
189
|
+
Fezzik comes with a DSL module that you can optionally include in the top level of your Rakefiles. It exposes
|
190
|
+
the following functions:
|
191
|
+
|
192
|
+
```
|
193
|
+
destination
|
194
|
+
env
|
195
|
+
capture_output
|
196
|
+
```
|
197
|
+
|
198
|
+
This lets you write your configuration more tersely:
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
include Fezzik::DSL
|
202
|
+
|
203
|
+
destination :prod do
|
204
|
+
env :rack_env, "production"
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
186
208
|
## Tasks
|
187
209
|
|
188
210
|
Fezzik has a number of useful tasks other than deploy.rake and environment.rake. These can also be downloaded
|
data/fezzik.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.homepage = "http://github.com/dmacdougall/fezzik"
|
19
19
|
s.rubyforge_project = "fezzik"
|
20
20
|
|
21
|
-
s.executables = %w(fez
|
21
|
+
s.executables = %w(fez)
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
23
|
|
24
24
|
s.add_dependency("rake", "~>0.8.7")
|
data/lib/fezzik.rb
CHANGED
@@ -3,8 +3,9 @@ require "thread"
|
|
3
3
|
require "rake"
|
4
4
|
require "rake/remote_task"
|
5
5
|
require "colorize"
|
6
|
-
require "fezzik/base
|
7
|
-
require "fezzik/
|
8
|
-
require "fezzik/
|
9
|
-
require "fezzik/
|
10
|
-
require "fezzik/
|
6
|
+
require "fezzik/base"
|
7
|
+
require "fezzik/dsl"
|
8
|
+
require "fezzik/environment"
|
9
|
+
require "fezzik/io"
|
10
|
+
require "fezzik/util"
|
11
|
+
require "fezzik/version"
|
data/lib/fezzik/dsl.rb
ADDED
data/lib/fezzik/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fezzik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-02-
|
13
|
+
date: 2012-02-12 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156480180 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.8.7
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156480180
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake-remote_task
|
28
|
-
requirement: &
|
28
|
+
requirement: &2156479720 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 2.0.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2156479720
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: colorize
|
39
|
-
requirement: &
|
39
|
+
requirement: &2156479260 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,12 +44,11 @@ dependencies:
|
|
44
44
|
version: 0.5.8
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2156479260
|
48
48
|
description: A light deployment system that gets out of your way
|
49
49
|
email: dmacdougall@gmail.com
|
50
50
|
executables:
|
51
51
|
- fez
|
52
|
-
- fezify
|
53
52
|
extensions: []
|
54
53
|
extra_rdoc_files: []
|
55
54
|
files:
|
@@ -58,12 +57,11 @@ files:
|
|
58
57
|
- Gemfile.lock
|
59
58
|
- README.md
|
60
59
|
- Rakefile
|
61
|
-
- TODO.md
|
62
60
|
- bin/fez
|
63
|
-
- bin/fezify
|
64
61
|
- fezzik.gemspec
|
65
62
|
- lib/fezzik.rb
|
66
63
|
- lib/fezzik/base.rb
|
64
|
+
- lib/fezzik/dsl.rb
|
67
65
|
- lib/fezzik/environment.rb
|
68
66
|
- lib/fezzik/io.rb
|
69
67
|
- lib/fezzik/util.rb
|
data/TODO.md
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
## Features
|
2
|
-
* rollback
|
3
|
-
* rolling restarts
|
4
|
-
* parallel execution
|
5
|
-
* clear old releases
|
6
|
-
* better way to update recipes/core with gem updates
|
7
|
-
* figure out how to include/share common recipes
|
8
|
-
|
9
|
-
## Bugs
|
10
|
-
* symlink task links to a nonexistant directory when run in isolation
|
11
|
-
|
12
|
-
## Release Notes
|
13
|
-
* copy previous deployment to destination before rsync (for faster rsync)
|
14
|
-
* copy unsafe links with rsync (done with -L)
|
data/bin/fezify
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require "colorize"
|
3
|
-
require "fileutils"
|
4
|
-
|
5
|
-
files = {
|
6
|
-
"config/deploy.rb" => <<-'EOF',
|
7
|
-
# This is the configuration file for fezzik.
|
8
|
-
# Define variables here as you would for Vlad the Deployer.
|
9
|
-
# A full list of variables can be found here:
|
10
|
-
# http://hitsquad.rubyforge.org/vlad/doco/variables_txt.html
|
11
|
-
|
12
|
-
set :app, "app"
|
13
|
-
set :deploy_to, "/opt/#{app}"
|
14
|
-
set :release_path, "#{deploy_to}/releases/#{Time.now.strftime("%Y%m%d%H%M")}"
|
15
|
-
set :local_path, Dir.pwd
|
16
|
-
set :user, "root"
|
17
|
-
|
18
|
-
# Each destination is a set of machines and configurations to deploy to.
|
19
|
-
# You can deploy to a destination from the command line with:
|
20
|
-
# fez to_dev deploy
|
21
|
-
#
|
22
|
-
# :domain can be an array if you are deploying to multiple hosts.
|
23
|
-
#
|
24
|
-
# You can set environment variables that will be loaded at runtime on the server
|
25
|
-
# like this:
|
26
|
-
# env :rack_env, "production"
|
27
|
-
# or
|
28
|
-
# env :error_monitoring, "true", ["prod12.com"]
|
29
|
-
# The second form specifies an environment variable particular to a server or list of servers (as a subset of
|
30
|
-
# the :domain list).
|
31
|
-
#
|
32
|
-
# This will also generate a file on the server named config/environment.rb, which you can include
|
33
|
-
# in your code to load these variables as Ruby constants. You can create your own config/environment.rb
|
34
|
-
# file to use for development, and it will be overwritten at runtime.
|
35
|
-
|
36
|
-
destination :dev do
|
37
|
-
set :domain, "#{user}@dev.example.com"
|
38
|
-
end
|
39
|
-
|
40
|
-
destination :prod do
|
41
|
-
set :domain, "#{user}@prod.example.com"
|
42
|
-
end
|
43
|
-
EOF
|
44
|
-
|
45
|
-
"config/recipes/core.rb" => <<-'EOF',
|
46
|
-
require "fileutils"
|
47
|
-
|
48
|
-
# This file contains core tasks that are used to deploy your application to the
|
49
|
-
# destination servers. This is a decent initial setup, but is completely configurable.
|
50
|
-
|
51
|
-
namespace :fezzik do
|
52
|
-
# Any variables set in deploy.rb with "env" will be saved on the server in two files:
|
53
|
-
# config/environment.sh and config/environment.rb. The first is loaded into the shell
|
54
|
-
# environment before the run script is called, and the second is made available to
|
55
|
-
# be required into your code. You can use your own environment.rb file for development,
|
56
|
-
# and it will be overwritten by this task when the code deploys.
|
57
|
-
desc "saves variables set by 'env' in deploy.rb into config/environment.sh and config/environment.rb"
|
58
|
-
task :save_environment do
|
59
|
-
@per_server_environments.each do |server, environment|
|
60
|
-
root_config_dir = "/tmp/#{app}/#{server}_config"
|
61
|
-
FileUtils.mkdir_p root_config_dir
|
62
|
-
File.open(File.join(root_config_dir, "environment.rb"), "w") do |file|
|
63
|
-
environment.each do |key, value|
|
64
|
-
quote = value.is_a?(Numeric) ? '' : '"'
|
65
|
-
file.puts "#{key.to_s.upcase} = #{quote}#{value}#{quote}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
File.open(File.join(root_config_dir, "environment.sh"), "w") do |file|
|
69
|
-
environment.each { |key, value| file.puts %[export #{key.to_s.upcase}="#{value}"] }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
desc "stages the project for deployment in /tmp"
|
75
|
-
task :stage do
|
76
|
-
puts "staging project in /tmp/#{app}"
|
77
|
-
FileUtils.rm_rf "/tmp/#{app}"
|
78
|
-
FileUtils.mkdir_p "/tmp/#{app}/staged"
|
79
|
-
FileUtils.cp_r "#{local_path}/.", "/tmp/#{app}/staged"
|
80
|
-
Rake::Task["fezzik:save_environment"].invoke
|
81
|
-
end
|
82
|
-
|
83
|
-
desc "performs any necessary setup on the destination servers prior to deployment"
|
84
|
-
remote_task :setup do
|
85
|
-
puts "setting up servers"
|
86
|
-
run "mkdir -p #{deploy_to}/releases"
|
87
|
-
end
|
88
|
-
|
89
|
-
desc "rsyncs the project from its stages location to each destination server"
|
90
|
-
remote_task :push => [:stage, :setup] do
|
91
|
-
puts "pushing to #{target_host}:#{release_path}"
|
92
|
-
# Copy on top of previous release to optimize rsync
|
93
|
-
rsync "-q", "--copy-dest=#{current_path}", "/tmp/#{app}/staged/", "#{target_host}:#{release_path}"
|
94
|
-
# Copy over the appropriate configs for the target
|
95
|
-
server = target_host.gsub(/^.*@/, "")
|
96
|
-
["environment.rb", "environment.sh"].each do |config_file|
|
97
|
-
rsync "-q", "/tmp/#{app}/#{server}_config/#{config_file}",
|
98
|
-
"#{target_host}:#{release_path}/config/#{config_file}"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
desc "symlinks the latest deployment to /deploy_path/project/current"
|
103
|
-
remote_task :symlink do
|
104
|
-
puts "symlinking current to #{release_path}"
|
105
|
-
run "cd #{deploy_to} && ln -fns #{release_path} current"
|
106
|
-
end
|
107
|
-
|
108
|
-
desc "runs the executable in project/bin"
|
109
|
-
remote_task :start do
|
110
|
-
puts "starting from #{capture_output { run "readlink #{current_path}" }}"
|
111
|
-
run "cd #{current_path} && source config/environment.sh && ./bin/run_app.sh"
|
112
|
-
end
|
113
|
-
|
114
|
-
desc "kills the application by searching for the specified process name"
|
115
|
-
remote_task :stop do
|
116
|
-
puts "stopping app"
|
117
|
-
# Replace YOUR_APP_NAME with whatever is run from your bin/run_app.sh file.
|
118
|
-
# run "(kill -9 `ps aux | grep 'YOUR_APP_NAME' | grep -v grep | awk '{print $2}'` || true)"
|
119
|
-
end
|
120
|
-
|
121
|
-
desc "restarts the application"
|
122
|
-
remote_task :restart do
|
123
|
-
Rake::Task["fezzik:stop"].invoke
|
124
|
-
Rake::Task["fezzik:start"].invoke
|
125
|
-
end
|
126
|
-
|
127
|
-
desc "full deployment pipeline"
|
128
|
-
task :deploy do
|
129
|
-
Rake::Task["fezzik:push"].invoke
|
130
|
-
Rake::Task["fezzik:symlink"].invoke
|
131
|
-
Rake::Task["fezzik:restart"].invoke
|
132
|
-
puts "#{app} deployed!"
|
133
|
-
end
|
134
|
-
end
|
135
|
-
EOF
|
136
|
-
|
137
|
-
"bin/run_app.sh" => <<-'EOF'
|
138
|
-
#!/bin/sh
|
139
|
-
# This file will be called to start your application.
|
140
|
-
EOF
|
141
|
-
}
|
142
|
-
|
143
|
-
FileUtils.mkdir_p "config/recipes"
|
144
|
-
FileUtils.mkdir_p "bin"
|
145
|
-
|
146
|
-
files.each do |filename, content|
|
147
|
-
if File.exists?(filename) && ARGV[0] != "-f"
|
148
|
-
puts " [skip] #{filename} already exists"
|
149
|
-
else
|
150
|
-
puts " [new] #{filename} created".green
|
151
|
-
File.open(filename, "w") { |file| file.write(content) }
|
152
|
-
system("chmod a+x bin/run_app.sh") if filename == "bin/run_app.sh"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
puts " [done]".green
|