sunraise 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +63 -0
- data/bin/sunraise +10 -2
- data/lib/config.rb +1 -2
- data/lib/deployer.rb +6 -6
- data/lib/generator.rb +40 -0
- data/sunraise-template.erb +17 -0
- data/sunraise.gemspec +8 -3
- metadata +45 -10
- data/sunraise.example +0 -12
data/README.md
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
####Sunraise is super fast, rails oriented deploying tool with clean and dead simple configuration
|
3
|
+
## Usage
|
4
|
+
Intalling:
|
5
|
+
|
6
|
+
gem install sunraise
|
7
|
+
cd /my/project/path
|
8
|
+
sunraise generate
|
9
|
+
# edit generated sunraise file
|
10
|
+
|
11
|
+
Deploying:
|
12
|
+
|
13
|
+
sunraise
|
14
|
+
|
15
|
+
## How it works
|
16
|
+
|
17
|
+
When you have big repository, deploying via capistrano takes a long time, becouse it fetching all project from git every time. You can go to ssh and do *git pull origin*; it will be very fast.
|
18
|
+
|
19
|
+
When you deploying with Sunraise, it doing something like this
|
20
|
+
|
21
|
+
git reset HEAD --hard
|
22
|
+
git pull origin master
|
23
|
+
# restart web server
|
24
|
+
|
25
|
+
But also it
|
26
|
+
|
27
|
+
* saves previous release
|
28
|
+
* make links to shared folders
|
29
|
+
* checks rails for working (runs script/about)
|
30
|
+
* and run migrations
|
31
|
+
|
32
|
+
## Configuring
|
33
|
+
|
34
|
+
Deloy config file contain usual ruby code
|
35
|
+
Available methods:
|
36
|
+
|
37
|
+
* **remote_host** - production servername
|
38
|
+
* **remote_user** - user to login via ssh
|
39
|
+
* **deploy_to** - path for deploy folder
|
40
|
+
* **then_link_to** - link to other place, don't make link if not specified
|
41
|
+
* **git_url** - repository path, it fetches code from it
|
42
|
+
* **shared_dirs** - (hash) folders what will be stored outside of project, and will be linking to it (usefull for attachments)
|
43
|
+
* **linked_dirs** - (array) the same with shared_dirs, but stored in other folder
|
44
|
+
* **local_project_path** - (default '.') project location
|
45
|
+
* **verbose** - (bool) if true** - showing ssh comands
|
46
|
+
* **force** - (bool) deploy even no new commits
|
47
|
+
* **release** - (bool, default true) don't replace with release folder if false
|
48
|
+
* **remake** - (bool) removes current deploy folder and initiate again
|
49
|
+
* **test_rails_app** - (bool, default true) test if rails app working, by running script/about
|
50
|
+
* **auto_migrate** - run rake db:migrate after deploy
|
51
|
+
* **destroy** - destroy deploy folder on remote host
|
52
|
+
|
53
|
+
parameters
|
54
|
+
|
55
|
+
* destroy
|
56
|
+
* remake
|
57
|
+
* verbose
|
58
|
+
* force
|
59
|
+
* release
|
60
|
+
|
61
|
+
Can be specified by command line, for more information see
|
62
|
+
|
63
|
+
sunraise -h
|
data/bin/sunraise
CHANGED
@@ -4,10 +4,16 @@ require 'rubygems'
|
|
4
4
|
require 'rainbow'
|
5
5
|
|
6
6
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'config')
|
7
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'deployer')
|
8
7
|
|
9
8
|
include SunRaise::PubConf
|
10
9
|
|
10
|
+
SunRaise::Config.instance
|
11
|
+
|
12
|
+
if ARGV == ['generate']
|
13
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'generator')
|
14
|
+
SunRaise::Generator.run
|
15
|
+
exit
|
16
|
+
end
|
11
17
|
|
12
18
|
if File.expand_path(__FILE__) == File.expand_path(File.join(Dir.pwd, 'sunraise'))
|
13
19
|
puts "Run it from you app folder, containing sunraise file with deploy instructions"
|
@@ -15,10 +21,12 @@ if File.expand_path(__FILE__) == File.expand_path(File.join(Dir.pwd, 'sunraise')
|
|
15
21
|
end
|
16
22
|
|
17
23
|
unless File.file?(File.join Dir.pwd, 'sunraise')
|
18
|
-
puts "
|
24
|
+
puts "./sunraise".color(:green) + " file not found in current directory"
|
25
|
+
puts "Run " + "sunraise generate".color(:green) + " to generate it or create it manualy"
|
19
26
|
exit
|
20
27
|
end
|
21
28
|
|
29
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'deployer')
|
22
30
|
|
23
31
|
at_exit { SunRaise::Deployer.new.go! }
|
24
32
|
|
data/lib/config.rb
CHANGED
@@ -48,7 +48,6 @@ module SunRaise
|
|
48
48
|
:auto_migrate => true,
|
49
49
|
:help => false
|
50
50
|
}
|
51
|
-
|
52
51
|
cl_options
|
53
52
|
end
|
54
53
|
|
@@ -57,7 +56,7 @@ module SunRaise
|
|
57
56
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |verbose|
|
58
57
|
@conf[:verbose] = verbose
|
59
58
|
end
|
60
|
-
|
59
|
+
|
61
60
|
opts.on("-f", "--[no-]force", "Deploy even there are no new commits") do |force|
|
62
61
|
@conf[:force] = force
|
63
62
|
end
|
data/lib/deployer.rb
CHANGED
@@ -65,9 +65,10 @@ module SunRaise
|
|
65
65
|
"mv .git_temp #{@new_dir}/.git", # move git in pre_release folder
|
66
66
|
]
|
67
67
|
|
68
|
-
ssh_exec (conf[:shared_dirs] + conf[:linked_dirs]).map {|dir| "rm #{deploy_path}/#{@new_dir}/#{dir}" }
|
68
|
+
ssh_exec (conf[:shared_dirs].keys + conf[:linked_dirs]).map {|dir| "rm #{deploy_path}/#{@new_dir}/#{dir}" }
|
69
69
|
|
70
70
|
ssh_exec [
|
71
|
+
"cd #{deploy_path}",
|
71
72
|
"cd #{@new_dir}",
|
72
73
|
"git reset HEAD --hard",
|
73
74
|
"git pull origin master"
|
@@ -106,9 +107,9 @@ module SunRaise
|
|
106
107
|
|
107
108
|
def make_links dist_dir
|
108
109
|
links = []
|
109
|
-
conf[:shared_dirs].each do |
|
110
|
+
conf[:shared_dirs].each do |dir, link_to|
|
110
111
|
links << "rm #{dir} -rf"
|
111
|
-
links << "mkdir #{deploy_path}/shared/#{
|
112
|
+
links << "mkdir #{deploy_path}/shared/#{link_to} -p"
|
112
113
|
links << "ln -s #{deploy_path}/shared/#{link_to} #{dir}"
|
113
114
|
end
|
114
115
|
|
@@ -157,7 +158,7 @@ module SunRaise
|
|
157
158
|
local_about = `#{File.join conf[:local_project_path], 'script', 'about'}`
|
158
159
|
local_migration_version = local_about.match(/Database schema version\s+ ([0-9]+)/)[1]
|
159
160
|
if remote_magration_version == local_migration_version
|
160
|
-
|
161
|
+
log_ok "No new migrations"
|
161
162
|
else
|
162
163
|
log_ok "Rinning rake db:migrate"
|
163
164
|
puts ssh_exec ["cd #{File.join deploy_path, dir}", "rake db:migrate RAILS_ENV=production"] # run migrations
|
@@ -201,5 +202,4 @@ module SunRaise
|
|
201
202
|
end
|
202
203
|
|
203
204
|
end
|
204
|
-
end
|
205
|
-
|
205
|
+
end
|
data/lib/generator.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'erb'
|
2
|
+
module SunRaise
|
3
|
+
# generates sunraise file
|
4
|
+
class Generator
|
5
|
+
def self.run
|
6
|
+
|
7
|
+
# check if ./sunrise already exists
|
8
|
+
if File.file? './sunraise'
|
9
|
+
puts 'file ' + 'sunraise'.color(:blue) + ' already exists'
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
# check .git folder
|
14
|
+
unless File.directory? './.git'
|
15
|
+
puts 'no ' + '.git'.color(:blue) + ' directory found'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
# detecting origins
|
20
|
+
git = `git remote -v | grep origin`
|
21
|
+
|
22
|
+
# parse git url
|
23
|
+
remote = git.split("\n").first.split(" ")[1]
|
24
|
+
|
25
|
+
# parse project name
|
26
|
+
# git@github.com:Paxa/ShopFront.git => ShopFront
|
27
|
+
dir = remote.match(/.+@.+:.+\/(.+)\.git/)[1]
|
28
|
+
|
29
|
+
# calculate executing path
|
30
|
+
bin_dir = File.dirname File.expand_path(__FILE__)
|
31
|
+
# open and render template
|
32
|
+
template = ERB.new File.new(File.join bin_dir, '../sunraise-template.erb').read
|
33
|
+
result_content = template.result(binding)
|
34
|
+
# write it to file
|
35
|
+
File.open('./sunraise', 'w') {|f| f.write result_content }
|
36
|
+
puts 'file ' + 'sunraise'.color(:blue) + ' successfuly created'
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
remote_host 'production-server.com'
|
2
|
+
remote_user 'root'
|
3
|
+
|
4
|
+
git_url '<%= remote %>'
|
5
|
+
|
6
|
+
|
7
|
+
deploy_to '/srv/deploy/<%= dir %>'
|
8
|
+
then_link_to '/srv/www/<%= dir %>'
|
9
|
+
|
10
|
+
shared_dirs 'public/system' => 'images'
|
11
|
+
|
12
|
+
linked_dirs ['log', 'tmp']
|
13
|
+
|
14
|
+
after_deploy do
|
15
|
+
log_ok "Restarting apps"
|
16
|
+
ssh_exec ["cd #{app_path}", 'thin stop -C config/thin.yml', 'thin start -C config/thin.yml']
|
17
|
+
end
|
data/sunraise.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "sunraise"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.4"
|
4
4
|
s.summary = "Super-fast and simple rails deployment."
|
5
5
|
s.description = "Super-fast and simple rails deployment"
|
6
6
|
s.author = "Pavel Evstigneev"
|
@@ -9,18 +9,23 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.has_rdoc = false
|
10
10
|
s.executables = ["sunraise"]
|
11
11
|
s.rubyforge_project = "sunraise"
|
12
|
-
s.files = [ "bin/sunraise", "lib/config.rb", "lib/deployer.rb",
|
12
|
+
s.files = [ "bin/sunraise", "lib/config.rb", "lib/deployer.rb",
|
13
|
+
"lib/generator.rb", "README.md", "sunraise.gemspec", 'sunraise-template.erb', 'lib/generator.rb']
|
13
14
|
|
14
15
|
if s.respond_to? :specification_version then
|
15
16
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
16
17
|
s.specification_version = 3
|
17
18
|
|
18
19
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
19
|
-
s.
|
20
|
+
s.add_runtime_dependency(%q<rainbow>, [">= 1.0.4"])
|
21
|
+
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.23"])
|
22
|
+
|
20
23
|
else
|
21
24
|
s.add_dependency(%q<rainbow>, [">= 1.0.4"])
|
25
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.23"])
|
22
26
|
end
|
23
27
|
else
|
24
28
|
s.add_dependency(%q<rainbow>, [">= 1.0.4"])
|
29
|
+
s.add_dependency(%q<net-ssh>, [">= 2.0.23"])
|
25
30
|
end
|
26
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunraise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Pavel Evstigneev
|
@@ -9,19 +15,41 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-06-09 00:00:00 +04:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rainbow
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 31
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 4
|
23
34
|
version: 1.0.4
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: net-ssh
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 33
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 23
|
50
|
+
version: 2.0.23
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
25
53
|
description: Super-fast and simple rails deployment
|
26
54
|
email: pavel.evst@gmail.com
|
27
55
|
executables:
|
@@ -34,9 +62,10 @@ files:
|
|
34
62
|
- bin/sunraise
|
35
63
|
- lib/config.rb
|
36
64
|
- lib/deployer.rb
|
65
|
+
- lib/generator.rb
|
37
66
|
- README.md
|
38
67
|
- sunraise.gemspec
|
39
|
-
- sunraise.
|
68
|
+
- sunraise-template.erb
|
40
69
|
has_rdoc: true
|
41
70
|
homepage: http://github.com/Paxa/sunraise
|
42
71
|
licenses: []
|
@@ -47,21 +76,27 @@ rdoc_options: []
|
|
47
76
|
require_paths:
|
48
77
|
- lib
|
49
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
50
80
|
requirements:
|
51
81
|
- - ">="
|
52
82
|
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
53
86
|
version: "0"
|
54
|
-
version:
|
55
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
56
89
|
requirements:
|
57
90
|
- - ">="
|
58
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
59
95
|
version: "0"
|
60
|
-
version:
|
61
96
|
requirements: []
|
62
97
|
|
63
98
|
rubyforge_project: sunraise
|
64
|
-
rubygems_version: 1.3.
|
99
|
+
rubygems_version: 1.3.7
|
65
100
|
signing_key:
|
66
101
|
specification_version: 3
|
67
102
|
summary: Super-fast and simple rails deployment.
|
data/sunraise.example
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
remote_host 'twews.com'
|
2
|
-
remote_user 'root'
|
3
|
-
|
4
|
-
git_url 'git://github.com/Paxa/sunraise_test_app.git'
|
5
|
-
|
6
|
-
deploy_to '/tmp/deploy/suntest'
|
7
|
-
then_link_to '/tmp/www/suntest'
|
8
|
-
|
9
|
-
shared_dirs 'public/stylesheets' => 'css', 'public/javascript' => 'js'
|
10
|
-
linked_dirs ['logs', 'tmp']
|
11
|
-
|
12
|
-
local_project_path "/home/paxa/Dropbox/sunraise/test/suntest"
|