fezzik 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +36 -0
- data/TODO +1 -0
- data/bin/fez +12 -0
- data/bin/fezify +120 -0
- data/fezzik.gemspec +25 -0
- data/lib/fezzik.rb +30 -0
- metadata +73 -0
data/README
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Fezzik
|
2
|
+
|
3
|
+
Fezzik (or fez) is a slim and snappy alternative to Capistrano.
|
4
|
+
|
5
|
+
It sets up a rake-based rsync workflow with a single configuration file
|
6
|
+
and gets out of your way.
|
7
|
+
|
8
|
+
## Install
|
9
|
+
|
10
|
+
sudo gem install fezzik
|
11
|
+
|
12
|
+
## Setup
|
13
|
+
$ cd myproject
|
14
|
+
$ ls
|
15
|
+
server.rb
|
16
|
+
$ fezify
|
17
|
+
[new] bin/run_app.sh created
|
18
|
+
[new] config/recipes/core.rb created
|
19
|
+
[new] config/deploy.rb created
|
20
|
+
[done]
|
21
|
+
|
22
|
+
**config/deploy.rb**: set your app name and destination servers
|
23
|
+
set :app, "fezzik"
|
24
|
+
...
|
25
|
+
destination :prod do
|
26
|
+
set :domain, "www.fezzik.com"
|
27
|
+
end
|
28
|
+
|
29
|
+
**bin/run_app.sh**: write a command that will start your app
|
30
|
+
#!/bin/sh
|
31
|
+
nohup ruby server.rb &
|
32
|
+
|
33
|
+
Ready to deploy!
|
34
|
+
$ fez to_prod deploy
|
35
|
+
...
|
36
|
+
fezzik deployed!
|
data/bin/fez
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "rake"
|
5
|
+
require "rake/remote_task"
|
6
|
+
require "fezzik"
|
7
|
+
|
8
|
+
# Include everything in config/recipes
|
9
|
+
Dir[File.join(Dir.pwd, 'config/recipes/**/*.rb')].sort.each { |lib| require lib }
|
10
|
+
|
11
|
+
Rake.application["fezzik:run"].invoke
|
12
|
+
|
data/bin/fezify
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
files = {
|
4
|
+
"config/deploy.rb" => <<-EOF,
|
5
|
+
# This is the configuration file for fezzik.
|
6
|
+
# Define variables here as you would for Vlad the Deployer.
|
7
|
+
# A full list of variables can be found here:
|
8
|
+
# http://hitsquad.rubyforge.org/vlad/doco/variables_txt.html
|
9
|
+
|
10
|
+
set :app, "app"
|
11
|
+
set :deploy_to, "/opt/#\{app\}"
|
12
|
+
set :release_path, "#\{deploy_to\}/releases/#\{Time.now.strftime("%Y%m%d%H%M")\}"
|
13
|
+
set :local_path, Dir.pwd
|
14
|
+
set :user, "root"
|
15
|
+
|
16
|
+
|
17
|
+
# Each destination is a set of machines and configurations to deploy to.
|
18
|
+
# You can deploy to a destination from the command line with:
|
19
|
+
# fez to_dev deploy
|
20
|
+
#
|
21
|
+
# :domain can be an array if you are deploying to multiple hosts.
|
22
|
+
#
|
23
|
+
# You can set environment variables that will be loaded at runtime on the server
|
24
|
+
# like this:
|
25
|
+
# env :rack_env, "production"
|
26
|
+
|
27
|
+
destination :dev do
|
28
|
+
set :domain, "#\{user\}@dev.example.com"
|
29
|
+
end
|
30
|
+
|
31
|
+
destination :prod do
|
32
|
+
set :domain, "#\{user\}@prod.example.com"
|
33
|
+
end
|
34
|
+
EOF
|
35
|
+
|
36
|
+
"config/recipes/core.rb" => <<-EOF,
|
37
|
+
# This file contains core tasks that are used to deploy your application to the
|
38
|
+
# destination servers. This is a decent initial setup, but is completely configurable.
|
39
|
+
|
40
|
+
namespace :fezzik do
|
41
|
+
task :save_environment do
|
42
|
+
system("mkdir -p /tmp/#\{app\}/config")
|
43
|
+
File.open("/tmp/#\{app\}/config/environment.rb", "w") do |file|
|
44
|
+
@environment.each do |key, value|
|
45
|
+
file.puts "#\{key.to_s.upcase\}=\\"#\{value\}\\""
|
46
|
+
end
|
47
|
+
end
|
48
|
+
File.open("/tmp/#\{app\}/config/environment.sh", "w") do |file|
|
49
|
+
@environment.each do |key, value|
|
50
|
+
file.puts "export #\{key.to_s.upcase\}=\\"#\{value\}\\""
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
task :stage do
|
56
|
+
puts "staging project in /tmp/#\{app\}"
|
57
|
+
system("rm -fr /tmp/#\{app\}")
|
58
|
+
system("cp -r #\{local_path\} /tmp/#\{app\}")
|
59
|
+
Rake::Task["fezzik:save_environment"].invoke
|
60
|
+
end
|
61
|
+
|
62
|
+
remote_task :setup do
|
63
|
+
puts "setting up servers"
|
64
|
+
run "mkdir -p #\{deploy_to\}/releases"
|
65
|
+
end
|
66
|
+
|
67
|
+
remote_task :push => [:stage, :setup] do
|
68
|
+
rsync "/tmp/#\{app\}/", "#\{target_host\}:#\{release_path\}"
|
69
|
+
end
|
70
|
+
|
71
|
+
remote_task :symlink => :push do
|
72
|
+
puts "symlinking current to #\{release_path\}"
|
73
|
+
run "cd #\{deploy_to\} && ln -fns #\{release_path\} current"
|
74
|
+
end
|
75
|
+
|
76
|
+
remote_task :start do
|
77
|
+
puts "starting from #\{release_path\}"
|
78
|
+
run "cd #\{current_path\} && source config/environment.sh" +
|
79
|
+
" && ./bin/run_app.sh"
|
80
|
+
end
|
81
|
+
|
82
|
+
remote_task :stop do
|
83
|
+
puts "stopping app"
|
84
|
+
# Replace YOUR_APP_NAME with whatever is run from your bin/run_app.sh file.
|
85
|
+
# run "(kill -9 `ps aux | grep 'YOUR_APP_NAME' | grep -v grep | awk '\{print $2\}'` || true)"
|
86
|
+
end
|
87
|
+
|
88
|
+
remote_task :restart do
|
89
|
+
Rake::Task["fezzik:stop"].invoke
|
90
|
+
Rake::Task["fezzik:start"].invoke
|
91
|
+
end
|
92
|
+
|
93
|
+
task :deploy => [:symlink, :restart] do
|
94
|
+
puts "#\{app\} deployed!"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
EOF
|
98
|
+
|
99
|
+
"bin/run_app.sh" => <<-EOF
|
100
|
+
#!/bin/sh
|
101
|
+
# This file will be called to start your application.
|
102
|
+
EOF
|
103
|
+
}
|
104
|
+
|
105
|
+
system("mkdir -p config/recipes")
|
106
|
+
system("mkdir -p bin")
|
107
|
+
|
108
|
+
files.each do |filename, content|
|
109
|
+
if File.exists?(filename) && ARGV[0] != "-f"
|
110
|
+
puts " [skip] #{filename} already exists"
|
111
|
+
else
|
112
|
+
puts " [new] #{filename} created"
|
113
|
+
File.open(filename, "w") { |file| file.write(content) }
|
114
|
+
if filename == "bin/run_app.sh"
|
115
|
+
system("chmod a+x bin/run_app.sh")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
puts " [done]"
|
data/fezzik.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "fezzik"
|
3
|
+
s.version = "0.1.0"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">=0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
7
|
+
|
8
|
+
s.author = "Daniel MacDougall"
|
9
|
+
s.email = "dmacdougall@gmail.com"
|
10
|
+
|
11
|
+
s.description = "A light deployment system that gets out of your way"
|
12
|
+
s.summary = "A light deployment system that gets out of your way"
|
13
|
+
s.homepage = "http://github.com/dmacdougall/fezzik"
|
14
|
+
s.rubyforge_project = "fezzik"
|
15
|
+
|
16
|
+
s.executables = %w(fez fezify)
|
17
|
+
s.files = %w(
|
18
|
+
README
|
19
|
+
TODO
|
20
|
+
fezzik.gemspec
|
21
|
+
lib/fezzik.rb
|
22
|
+
bin/fez
|
23
|
+
bin/fezify
|
24
|
+
)
|
25
|
+
end
|
data/lib/fezzik.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
namespace :fezzik do
|
2
|
+
task :run do
|
3
|
+
if ARGV.size == 0
|
4
|
+
puts " Usage: fez to_destination task"
|
5
|
+
exit 1
|
6
|
+
end
|
7
|
+
destination = ARGV[0]
|
8
|
+
destination = $1 if destination.match(/to_(.+)/)
|
9
|
+
tasks = ARGV[1..-1]
|
10
|
+
Rake::Task["fezzik:load_config"].invoke destination
|
11
|
+
tasks.each do |task|
|
12
|
+
Rake::Task["fezzik:#{task}"].invoke
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :load_config, :destination do |t, args|
|
17
|
+
@destination = args[:destination].to_sym
|
18
|
+
@environment = {}
|
19
|
+
require "config/deploy.rb"
|
20
|
+
puts "configuring for #{domain}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def destination(target, &block)
|
24
|
+
block.call if target == @destination
|
25
|
+
end
|
26
|
+
|
27
|
+
def env(key, value)
|
28
|
+
@environment[key] = value
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fezzik
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Daniel MacDougall
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-01 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A light deployment system that gets out of your way
|
23
|
+
email: dmacdougall@gmail.com
|
24
|
+
executables:
|
25
|
+
- fez
|
26
|
+
- fezify
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- README
|
33
|
+
- TODO
|
34
|
+
- fezzik.gemspec
|
35
|
+
- lib/fezzik.rb
|
36
|
+
- bin/fez
|
37
|
+
- bin/fezify
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/dmacdougall/fezzik
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: fezzik
|
68
|
+
rubygems_version: 1.6.0
|
69
|
+
signing_key:
|
70
|
+
specification_version: 2
|
71
|
+
summary: A light deployment system that gets out of your way
|
72
|
+
test_files: []
|
73
|
+
|