capricorn 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -1
- data/bin/capricornctl +1 -0
- data/bin/capricornutl +10 -0
- data/erlang/lib/capricorn/src/cap_cluster_gems.erl +3 -2
- data/erlang/lib/capricorn/src/cap_machine_apps.erl +3 -2
- data/lib/capricorn-client.rb +25 -16
- data/lib/capricorn-client/cli/applications/domains.rb +6 -2
- data/lib/capricorn-client/cli/applications/gems.rb +8 -4
- data/lib/capricorn-client/cli/builder.rb +48 -0
- data/lib/capricorn-client/cli/deployer.rb +27 -0
- data/lib/capricorn-client/cli/releaser.rb +30 -0
- data/lib/capricorn-util.rb +35 -0
- data/lib/capricorn-util/internal.rb +68 -0
- data/lib/capricorn/version.rb +1 -1
- metadata +11 -8
- data/bin/capricorn-app-scaffolder +0 -27
- data/bin/capricorn-gem-spec +0 -33
data/README.md
CHANGED
data/bin/capricornctl
CHANGED
data/bin/capricornutl
ADDED
@@ -161,8 +161,9 @@ code_change(_OldVsn, State, _Extra) ->
|
|
161
161
|
|
162
162
|
-spec start_spec_reader(state()) -> state() .
|
163
163
|
start_spec_reader(State) ->
|
164
|
-
RubyCmd = os:find_executable("
|
165
|
-
SpecReader = bertio:open_port({spawn_executable, RubyCmd}, [
|
164
|
+
RubyCmd = os:find_executable("capricornutl"),
|
165
|
+
SpecReader = bertio:open_port({spawn_executable, RubyCmd}, [
|
166
|
+
exit_status, {args, ["internal:inspector"]}]),
|
166
167
|
State#state{spec_reader=SpecReader}.
|
167
168
|
|
168
169
|
|
@@ -230,8 +230,9 @@ code_change(_OldVsn, State, _Extra) ->
|
|
230
230
|
|
231
231
|
|
232
232
|
start_scaffolder(State) ->
|
233
|
-
Cmd = os:find_executable("
|
234
|
-
Port = bertio:open_port({spawn_executable, Cmd}, [
|
233
|
+
Cmd = os:find_executable("capricornutl"),
|
234
|
+
Port = bertio:open_port({spawn_executable, Cmd}, [
|
235
|
+
exit_status, {args, ["internal:scaffolder"]}]),
|
235
236
|
State#ctx{scaffolder=Port}.
|
236
237
|
|
237
238
|
|
data/lib/capricorn-client.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Capricorn
|
2
|
+
gem 'fd-bertrpc'
|
3
|
+
|
2
4
|
require 'thor'
|
3
5
|
require 'yaml'
|
4
6
|
require 'bertrpc'
|
@@ -14,6 +16,21 @@ module Capricorn
|
|
14
16
|
require 'capricorn-client/cli/applications/gems'
|
15
17
|
require 'capricorn-client/cli/gems'
|
16
18
|
require 'capricorn-client/cli/machines'
|
19
|
+
require 'capricorn-client/cli/builder'
|
20
|
+
require 'capricorn-client/cli/deployer'
|
21
|
+
require 'capricorn-client/cli/releaser'
|
22
|
+
|
23
|
+
def self.start(given_args = ARGV, config = {})
|
24
|
+
if self == Capricorn::CLI
|
25
|
+
case given_args[0]
|
26
|
+
when 'deploy'
|
27
|
+
given_args[0] = 'deploy:version'
|
28
|
+
when 'build'
|
29
|
+
given_args[0] = 'build:current'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
super(given_args, config)
|
33
|
+
end
|
17
34
|
|
18
35
|
def self.banner(task)
|
19
36
|
"#{banner_base} #{task.formatted_usage(self, true)}"
|
@@ -29,10 +46,14 @@ module Capricorn
|
|
29
46
|
end
|
30
47
|
|
31
48
|
def method_missing(meth, *args)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
49
|
+
if self.class == Capricorn::CLI
|
50
|
+
meth = meth.to_s
|
51
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
|
52
|
+
args.unshift(task) if task
|
53
|
+
klass.start(args, :shell => self.shell)
|
54
|
+
else
|
55
|
+
super
|
56
|
+
end
|
36
57
|
end
|
37
58
|
|
38
59
|
class_option :cluster, :type => :string, :aliases => ['-c']
|
@@ -40,18 +61,6 @@ module Capricorn
|
|
40
61
|
class_option :application, :type => :string, :aliases => ['-a', '--app']
|
41
62
|
class_option :environment, :type => :string, :aliases => ['-e', '--env']
|
42
63
|
|
43
|
-
desc "deploy", "deploy an new gem"
|
44
|
-
def deploy
|
45
|
-
last = Dir.glob("pkg/*.gem").sort do |a, b|
|
46
|
-
File.stat(a).mtime <=> File.stat(b).mtime
|
47
|
-
end.last
|
48
|
-
|
49
|
-
$capr_gems_weak_push = true
|
50
|
-
|
51
|
-
invoke "gems:push", [last]
|
52
|
-
invoke "apps:fupdate"
|
53
|
-
end
|
54
|
-
|
55
64
|
end
|
56
65
|
|
57
66
|
end
|
@@ -6,10 +6,10 @@ class Capricorn::CLI::ApplicationsDomains < Capricorn::CLI
|
|
6
6
|
|
7
7
|
desc "list", "list all domains"
|
8
8
|
def list
|
9
|
-
application_info[4].sort! do |a, b|
|
9
|
+
(application_info[4] || []).sort! do |a, b|
|
10
10
|
a <=> b
|
11
11
|
end
|
12
|
-
application_info[4].each do |domain|
|
12
|
+
(application_info[4] || []).each do |domain|
|
13
13
|
puts "- #{domain}"
|
14
14
|
end
|
15
15
|
end
|
@@ -27,6 +27,8 @@ class Capricorn::CLI::ApplicationsDomains < Capricorn::CLI
|
|
27
27
|
machine, id = *application
|
28
28
|
app = application_info
|
29
29
|
|
30
|
+
app[4] ||= []
|
31
|
+
|
30
32
|
if app[4].include?(domain)
|
31
33
|
halt "Domain is already configured"
|
32
34
|
end
|
@@ -49,6 +51,8 @@ class Capricorn::CLI::ApplicationsDomains < Capricorn::CLI
|
|
49
51
|
machine, id = *application
|
50
52
|
app = application_info
|
51
53
|
|
54
|
+
app[4] ||= []
|
55
|
+
|
52
56
|
unless app[4].include?(domain)
|
53
57
|
halt "Domain is not configured"
|
54
58
|
end
|
@@ -6,22 +6,22 @@ class Capricorn::CLI::ApplicationsGems < Capricorn::CLI
|
|
6
6
|
|
7
7
|
desc "list", "list all gems"
|
8
8
|
def list
|
9
|
-
application_info[9].sort! do |a,b|
|
9
|
+
(application_info[9] || []).sort! do |a,b|
|
10
10
|
a[1] <=> b[1]
|
11
11
|
end
|
12
12
|
|
13
|
-
application_info[10].sort! do |a,b|
|
13
|
+
(application_info[10] || []).sort! do |a,b|
|
14
14
|
a <=> b
|
15
15
|
end
|
16
16
|
|
17
17
|
puts "Configured gems:"
|
18
|
-
application_info[10].each do |name|
|
18
|
+
(application_info[10] || []).each do |name|
|
19
19
|
puts "- #{name}"
|
20
20
|
end
|
21
21
|
puts
|
22
22
|
|
23
23
|
puts "Used gems:"
|
24
|
-
application_info[9].each do |gem|
|
24
|
+
(application_info[9] || []).each do |gem|
|
25
25
|
puts "- #{gem[1]} (#{gem[2].flatten.join('.')})"
|
26
26
|
end
|
27
27
|
end
|
@@ -33,6 +33,8 @@ class Capricorn::CLI::ApplicationsGems < Capricorn::CLI
|
|
33
33
|
machine, id = *application
|
34
34
|
app = application_info
|
35
35
|
|
36
|
+
app[10] ||= []
|
37
|
+
|
36
38
|
if app[10].include?(gem_name)
|
37
39
|
halt "Gem is already configured"
|
38
40
|
end
|
@@ -49,6 +51,8 @@ class Capricorn::CLI::ApplicationsGems < Capricorn::CLI
|
|
49
51
|
machine, id = *application
|
50
52
|
app = application_info
|
51
53
|
|
54
|
+
app[10] ||= []
|
55
|
+
|
52
56
|
unless app[10].include?(gem_name)
|
53
57
|
halt "Gem is not configured"
|
54
58
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Capricorn::CLI::Builder < Capricorn::CLI
|
2
|
+
include Capricorn::Helpers
|
3
|
+
|
4
|
+
namespace :build
|
5
|
+
|
6
|
+
desc "current", "build the current version"
|
7
|
+
def current
|
8
|
+
system("rake build")
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "patch", "build a new patch"
|
12
|
+
def patch
|
13
|
+
check_clean_stage
|
14
|
+
bump_version(:patch)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "minor", "build a new minor"
|
18
|
+
def minor
|
19
|
+
check_clean_stage
|
20
|
+
bump_version(:minor)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "major", "build a new major"
|
24
|
+
def major
|
25
|
+
check_clean_stage
|
26
|
+
bump_version(:major)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def check_clean_stage
|
32
|
+
unless %x[ git status 2>&1 ].include?('nothing to commit (working directory clean)')
|
33
|
+
halt("Your git stage is not clean!")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def bump_version(level)
|
38
|
+
system("rake version:bump:#{level} build")
|
39
|
+
|
40
|
+
if %x[ rake version ] =~ /^Current\sversion[:]\s([\d.]+)$/im
|
41
|
+
$last_version = $1
|
42
|
+
system("git tag -a -m \"#{$last_version}\" #{$last_version}")
|
43
|
+
system("git push origin master")
|
44
|
+
system("git push origin master --tags")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Capricorn::CLI::Deployer < Capricorn::CLI
|
2
|
+
include Capricorn::Helpers
|
3
|
+
|
4
|
+
namespace :deploy
|
5
|
+
|
6
|
+
desc "version [VERSION]", "build the current version"
|
7
|
+
def version(version=nil)
|
8
|
+
gem = nil
|
9
|
+
if version
|
10
|
+
gem = Dir.glob("pkg/*-#{version}.gem").last
|
11
|
+
else
|
12
|
+
gem = Dir.glob("pkg/*.gem").sort do |a, b|
|
13
|
+
File.stat(a).mtime <=> File.stat(b).mtime
|
14
|
+
end.last
|
15
|
+
end
|
16
|
+
|
17
|
+
unless gem
|
18
|
+
halt "Please build a gem first!"
|
19
|
+
end
|
20
|
+
|
21
|
+
$capr_gems_weak_push = true
|
22
|
+
|
23
|
+
invoke "gems:push", [gem]
|
24
|
+
invoke "apps:fupdate"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Capricorn::CLI::Releaser < Capricorn::CLI
|
2
|
+
include Capricorn::Helpers
|
3
|
+
|
4
|
+
namespace :release
|
5
|
+
|
6
|
+
desc "patch", "release a new patch"
|
7
|
+
def patch
|
8
|
+
release_version(:patch)
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "minor", "release a new minor"
|
12
|
+
def minor
|
13
|
+
release_version(:minor)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "major", "release a new major"
|
17
|
+
def major
|
18
|
+
release_version(:major)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def release_version(level)
|
24
|
+
invoke "build:#{level}"
|
25
|
+
if $last_version
|
26
|
+
invoke "deploy:version", [$last_version]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Capricorn
|
2
|
+
require 'thor'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
class Util < Thor
|
6
|
+
namespace "default"
|
7
|
+
|
8
|
+
require 'capricorn-util/internal'
|
9
|
+
|
10
|
+
def self.banner(task)
|
11
|
+
"#{banner_base} #{task.formatted_usage(self, true)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def help(meth=nil)
|
15
|
+
if meth && !self.respond_to?(meth)
|
16
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
|
17
|
+
klass.start(["-h", task].compact, :shell => self.shell)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_missing(meth, *args)
|
24
|
+
if self.class == Capricorn::Util
|
25
|
+
meth = meth.to_s
|
26
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
|
27
|
+
args.unshift(task) if task
|
28
|
+
klass.start(args, :shell => self.shell)
|
29
|
+
else
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Capricorn::Util::Internal < Capricorn::Util
|
2
|
+
namespace :internal
|
3
|
+
|
4
|
+
require 'capricorn'
|
5
|
+
require 'rubygems/format'
|
6
|
+
|
7
|
+
desc "scaffolder", "scaffolder process for capricorn"
|
8
|
+
def scaffolder
|
9
|
+
Erlang do |cmd|
|
10
|
+
case cmd.shift
|
11
|
+
when :create
|
12
|
+
recipe = cmd.shift
|
13
|
+
app = convert_app(cmd.first)
|
14
|
+
|
15
|
+
recipe_path = File.expand_path("../../lib/capricorn/recipes/#{recipe}.rb", __FILE__)
|
16
|
+
ctx = Capricorn::SystemContext.run(recipe_path, :application => app)
|
17
|
+
|
18
|
+
send t[true, t[ctx.www_user, ctx.www_group, ctx.root_path]]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "inspector", "inspector process for capricorn"
|
24
|
+
def inspector
|
25
|
+
Erlang do |path|
|
26
|
+
|
27
|
+
unless File.extname(path) == ".gem" and File.file?(path)
|
28
|
+
error :not_found
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
format = Gem::Format.from_file_by_path(path)
|
33
|
+
rescue Exception => e
|
34
|
+
error :gem_error, e.message
|
35
|
+
end
|
36
|
+
|
37
|
+
spec = format.spec
|
38
|
+
unless spec
|
39
|
+
error :gem_error, "Invalid gem"
|
40
|
+
end
|
41
|
+
|
42
|
+
dependencies = spec.runtime_dependencies.collect do |dep|
|
43
|
+
version_requirements = dep.version_requirements.as_list.collect do |req|
|
44
|
+
op, version = *req.split(/\s+/, 2)
|
45
|
+
BERT::Tuple[op, version]
|
46
|
+
end
|
47
|
+
BERT::Tuple[dep.name, version_requirements]
|
48
|
+
end
|
49
|
+
|
50
|
+
send BERT::Tuple[spec.name, spec.version.to_s, dependencies]
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def convert_app(app)
|
58
|
+
application = {}
|
59
|
+
application[:id] = app[1]
|
60
|
+
application[:node] = app[2]
|
61
|
+
application[:name] = app[3]
|
62
|
+
application[:domain] = app[4].shift
|
63
|
+
application[:aliases] = app[4]
|
64
|
+
application[:environment] = app[5]
|
65
|
+
application
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/lib/capricorn/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capricorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 8
|
10
|
+
version: 2.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Simon Menke
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-16 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -120,8 +120,7 @@ email:
|
|
120
120
|
executables:
|
121
121
|
- capricornctl
|
122
122
|
- capricornd
|
123
|
-
-
|
124
|
-
- capricorn-gem-spec
|
123
|
+
- capricornutl
|
125
124
|
extensions:
|
126
125
|
- ext/extconf.rb
|
127
126
|
extra_rdoc_files: []
|
@@ -137,10 +136,15 @@ files:
|
|
137
136
|
- lib/capricorn-client/cli/applications/domains.rb
|
138
137
|
- lib/capricorn-client/cli/applications/gems.rb
|
139
138
|
- lib/capricorn-client/cli/applications.rb
|
139
|
+
- lib/capricorn-client/cli/builder.rb
|
140
|
+
- lib/capricorn-client/cli/deployer.rb
|
140
141
|
- lib/capricorn-client/cli/gems.rb
|
141
142
|
- lib/capricorn-client/cli/machines.rb
|
143
|
+
- lib/capricorn-client/cli/releaser.rb
|
142
144
|
- lib/capricorn-client/helpers.rb
|
143
145
|
- lib/capricorn-client.rb
|
146
|
+
- lib/capricorn-util/internal.rb
|
147
|
+
- lib/capricorn-util.rb
|
144
148
|
- lib/capricorn.rb
|
145
149
|
- erlang/lib/bert/doc/overview.edoc
|
146
150
|
- erlang/lib/bert/ebin/bert.app
|
@@ -207,8 +211,7 @@ files:
|
|
207
211
|
- README.md
|
208
212
|
- bin/capricornctl
|
209
213
|
- bin/capricornd
|
210
|
-
- bin/
|
211
|
-
- bin/capricorn-gem-spec
|
214
|
+
- bin/capricornutl
|
212
215
|
has_rdoc: true
|
213
216
|
homepage: http://github.com/fd/capricorn
|
214
217
|
licenses: []
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'capricorn'
|
4
|
-
|
5
|
-
def convert_app(app)
|
6
|
-
application = {}
|
7
|
-
application[:id] = app[1]
|
8
|
-
application[:node] = app[2]
|
9
|
-
application[:name] = app[3]
|
10
|
-
application[:domain] = app[4].shift
|
11
|
-
application[:aliases] = app[4]
|
12
|
-
application[:environment] = app[5]
|
13
|
-
application
|
14
|
-
end
|
15
|
-
|
16
|
-
Erlang do |cmd|
|
17
|
-
case cmd.shift
|
18
|
-
when :create
|
19
|
-
recipe = cmd.shift
|
20
|
-
app = convert_app(cmd.first)
|
21
|
-
|
22
|
-
recipe_path = File.expand_path("../../lib/capricorn/recipes/#{recipe}.rb", __FILE__)
|
23
|
-
ctx = Capricorn::SystemContext.run(recipe_path, :application => app)
|
24
|
-
|
25
|
-
send t[true, t[ctx.www_user, ctx.www_group, ctx.root_path]]
|
26
|
-
end
|
27
|
-
end
|
data/bin/capricorn-gem-spec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'capricorn'
|
4
|
-
require 'rubygems/format'
|
5
|
-
|
6
|
-
Erlang do |path|
|
7
|
-
|
8
|
-
unless File.extname(path) == ".gem" and File.file?(path)
|
9
|
-
error :not_found
|
10
|
-
end
|
11
|
-
|
12
|
-
begin
|
13
|
-
format = Gem::Format.from_file_by_path(path)
|
14
|
-
rescue Exception => e
|
15
|
-
error :gem_error, e.message
|
16
|
-
end
|
17
|
-
|
18
|
-
spec = format.spec
|
19
|
-
unless spec
|
20
|
-
error :gem_error, "Invalid gem"
|
21
|
-
end
|
22
|
-
|
23
|
-
dependencies = spec.runtime_dependencies.collect do |dep|
|
24
|
-
version_requirements = dep.version_requirements.as_list.collect do |req|
|
25
|
-
op, version = *req.split(/\s+/, 2)
|
26
|
-
BERT::Tuple[op, version]
|
27
|
-
end
|
28
|
-
BERT::Tuple[dep.name, version_requirements]
|
29
|
-
end
|
30
|
-
|
31
|
-
send BERT::Tuple[spec.name, spec.version.to_s, dependencies]
|
32
|
-
|
33
|
-
end
|