rails_pwnerer 0.6.22 → 0.6.23
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +1 -0
- data/README +4 -4
- data/lib/pwnage/app/cluster_config.rb +17 -5
- data/lib/pwnage/app/config.rb +8 -3
- data/lib/pwnage/base/cpus.rb +62 -0
- data/lib/pwnage/scaffolds/gems.rb +5 -2
- data/lib/pwnage/scaffolds/packages.rb +1 -1
- data/lib/rails_pwnerer.rb +1 -0
- data/rails_pwnerer.gemspec +8 -6
- metadata +5 -3
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
data/README
CHANGED
@@ -119,12 +119,12 @@ overrides will be version-controlled). In your Rails directory
|
|
119
119
|
* Set the DNS name that your app responds to:
|
120
120
|
rpwndev set dns-name your.dns.name
|
121
121
|
|
122
|
-
* Tweak the number of frontends for an instance:
|
123
|
-
rpwndev setnum
|
122
|
+
* Tweak the number of frontends per CPU core for an instance:
|
123
|
+
rpwndev setnum frontends_per_core 4 your_instance
|
124
124
|
|
125
125
|
* Delete the previous tweak and apply it to all instances:
|
126
|
-
rpwndev del
|
127
|
-
rpwndev setnum
|
126
|
+
rpwndev del frontends_per_core your_instance;
|
127
|
+
rpwndev setnum frontends_per_core 4
|
128
128
|
|
129
129
|
The overrides are YAML files in +config/rails_pwnage+, so you
|
130
130
|
can view and edit them by hand. rpwndev is just a handy tool,
|
@@ -24,16 +24,28 @@ class RailsPwnage::App::ClusterConfig
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# computes the number of frontends to bring up / down
|
28
|
+
def num_frontends(app_name, instance_name)
|
29
|
+
app_config = RailsPwnage::Config[app_name, instance_name]
|
30
|
+
return nil unless app_config and fixed_frontends = app_config[:frontends]
|
31
|
+
|
32
|
+
if app_config[:frontends_per_core]
|
33
|
+
cores_frontends = app_config[:frontends_per_core] * app_config[:detected_cores]
|
34
|
+
return cores_frontends unless cores_frontends == 0
|
35
|
+
end
|
36
|
+
return fixed_frontends
|
37
|
+
end
|
38
|
+
|
27
39
|
def manage_ports(app_name, instance_name, action)
|
28
40
|
app_config = RailsPwnage::Config[app_name, instance_name]
|
29
|
-
return unless
|
41
|
+
return unless frontends = num_frontends(app_name, instance_name)
|
30
42
|
|
31
43
|
case action
|
32
44
|
when :alloc
|
33
|
-
app_config[:port0] = RailsPwnage::Config.alloc_ports
|
45
|
+
app_config[:port0] = RailsPwnage::Config.alloc_ports frontends
|
34
46
|
when :free
|
47
|
+
RailsPwnage::Config.free_ports app_config[:port0], frontends
|
35
48
|
return if app_config[:port0] == 0 # do not release if ports have already been released
|
36
|
-
RailsPwnage::Config.free_ports app_config[:port0], app_config[:frontends]
|
37
49
|
app_config[:port0] = 0
|
38
50
|
end
|
39
51
|
RailsPwnage::Config.flush_db RailsPwnage::Config.app_db_name(app_name, instance_name)
|
@@ -45,7 +57,7 @@ class RailsPwnage::App::ClusterConfig
|
|
45
57
|
return unless app_config and File.exists? app_config[:app_path]
|
46
58
|
|
47
59
|
app_path = app_config[:app_path]
|
48
|
-
frontends, first_port =
|
60
|
+
frontends, first_port = num_frontends(app_name, instance_name), app_config[:port0]
|
49
61
|
|
50
62
|
cmdline_patterns = ['thin', nil]
|
51
63
|
|
@@ -69,7 +81,7 @@ class RailsPwnage::App::ClusterConfig
|
|
69
81
|
|
70
82
|
app_path, pwnerer_user = app_config[:app_path], app_config[:pwnerer_user]
|
71
83
|
pwnerer_group = group_for_username(pwnerer_user)
|
72
|
-
frontends, first_port =
|
84
|
+
frontends, first_port = num_frontends(app_name, instance_name), app_config[:port0]
|
73
85
|
environment = app_config[:environment]
|
74
86
|
|
75
87
|
stop app_name, instance_name
|
data/lib/pwnage/app/config.rb
CHANGED
@@ -8,7 +8,7 @@ class RailsPwnage::App::Config
|
|
8
8
|
(0...16).map { |i| "abcdefghijklmnopqrstuvwxyz"[rand(26),1]}.join
|
9
9
|
end
|
10
10
|
|
11
|
-
# fills
|
11
|
+
# fills inexistent keys with their default values
|
12
12
|
# setup: this effectively creates the baseline configuration db
|
13
13
|
# update: this adds keys that might have been added in new versions of rpwn
|
14
14
|
def populate_defaults(app_name, instance_name, app_db)
|
@@ -16,11 +16,13 @@ class RailsPwnage::App::Config
|
|
16
16
|
app_db[:app_path] = File.join(RailsPwnage::Config.path_to(:apps), app_name + '.' + instance_name)
|
17
17
|
# the path to application backups
|
18
18
|
app_db[:backup_path] ||= File.join(RailsPwnage::Config.path_to(:backups), app_name + '.' + instance_name)
|
19
|
-
|
19
|
+
|
20
20
|
# the user which will receive the "keys" to the production system
|
21
21
|
app_db[:pwnerer_user] ||= RailsPwnage::Config[:host][:pwnerer_user]
|
22
22
|
# the number of frontends for the application instance
|
23
|
-
app_db[:frontends] ||= 4
|
23
|
+
app_db[:frontends] ||= 4 # most computers have 2 cores nowadays
|
24
|
+
# the number of frontends per core for the application instance
|
25
|
+
app_db[:frontends_per_core] ||= 2 # best practice
|
24
26
|
# the first internal port for the application instance
|
25
27
|
app_db[:port0] = 0 # will be overwritten during allocation
|
26
28
|
# the name of the database for the application instance
|
@@ -43,6 +45,9 @@ class RailsPwnage::App::Config
|
|
43
45
|
app_db[:gems] ||= ''
|
44
46
|
# set to disable accidental db resets (on production vs. staging instances)
|
45
47
|
app_db[:enable_db_reset] ||= false
|
48
|
+
|
49
|
+
# the number of cores on the platform
|
50
|
+
app_db[:detected_cores] ||= cpu_cores.count
|
46
51
|
end
|
47
52
|
|
48
53
|
# allocates room for the application and creates the application configuration database
|
@@ -0,0 +1,62 @@
|
|
1
|
+
if File.exists? '/proc/cpuinfo'
|
2
|
+
# safest option: emulate Sys::CPU based on procfs
|
3
|
+
module Sys; end
|
4
|
+
|
5
|
+
module Sys::CPU
|
6
|
+
def self.processors
|
7
|
+
cpuinfo_text = File.read '/proc/cpuinfo'
|
8
|
+
cpus_text = cpuinfo_text.split "\n\n"
|
9
|
+
cpus = []
|
10
|
+
cpus_text.each do |cpu_text|
|
11
|
+
cpu = {}
|
12
|
+
cpu_text.each_line do |cpu_line|
|
13
|
+
key, value = *cpu_line.split(':', 2)
|
14
|
+
key.strip!
|
15
|
+
key.gsub! /\s/, '_'
|
16
|
+
key.downcase!
|
17
|
+
value.strip!
|
18
|
+
cpu[key.to_sym] = value
|
19
|
+
end
|
20
|
+
cpus << Struct.new(*cpu.keys).new(*cpu.values)
|
21
|
+
end
|
22
|
+
|
23
|
+
cpus.each { |cpu| yield cpu } if Kernel.block_given?
|
24
|
+
return cpus
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
else
|
29
|
+
# no procfs, try to use sys-cpu
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rubygems'
|
33
|
+
require 'sys/cpu'
|
34
|
+
rescue
|
35
|
+
# no gem either, stub sys-cpu
|
36
|
+
module Sys; end
|
37
|
+
|
38
|
+
module Sys::CPU
|
39
|
+
def self.processors
|
40
|
+
return []
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
module RailsPwnage::Base
|
48
|
+
# returns information for each core in the system
|
49
|
+
def cpu_cores
|
50
|
+
cpus = []
|
51
|
+
Sys::CPU.processors do |p|
|
52
|
+
cpus << {
|
53
|
+
:freq => p.cpu_mhz.to_f,
|
54
|
+
:id => p.processor.to_i,
|
55
|
+
:cpu => p.physical_id.to_i,
|
56
|
+
:core => p.core_id.to_i,
|
57
|
+
:num_cores => p.cpu_cores.to_i
|
58
|
+
}
|
59
|
+
end
|
60
|
+
return cpus
|
61
|
+
end
|
62
|
+
end
|
@@ -20,8 +20,11 @@ class RailsPwnage::Scaffolds::Gems
|
|
20
20
|
# we need this to do controlled app container startups
|
21
21
|
install_gems %w(sys-proctable)
|
22
22
|
|
23
|
-
#
|
24
|
-
install_gems %w(
|
23
|
+
# used to determine the number of available CPUs and cores
|
24
|
+
install_gems %w(sys-cpu)
|
25
|
+
|
26
|
+
# useful for building gems and debugging
|
27
|
+
install_gems %w(highline echoe)
|
25
28
|
end
|
26
29
|
|
27
30
|
# runner
|
@@ -14,7 +14,7 @@ class RailsPwnage::Scaffolds::Packages
|
|
14
14
|
# should work from source, except package author decided to block that
|
15
15
|
install_packages %w(subversion)
|
16
16
|
|
17
|
-
# rpwn doesn't deal with git
|
17
|
+
# rpwn doesn't deal with git yet, but we'd like to offer that, so we'll
|
18
18
|
# bring in the git infrastructure during scaffolding
|
19
19
|
install_packages %w(git-core), :source => true
|
20
20
|
|
data/lib/rails_pwnerer.rb
CHANGED
data/rails_pwnerer.gemspec
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = %q{rails_pwnerer}
|
3
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.23"
|
4
6
|
|
5
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
8
|
s.authors = ["Victor Costan"]
|
7
|
-
s.date = %q{2008-
|
9
|
+
s.date = %q{2008-12-31}
|
8
10
|
s.default_executable = %q{bin/rpwn}
|
9
11
|
s.description = %q{Rails deployment tool/hack.}
|
10
12
|
s.email = %q{victor@costan.us}
|
11
13
|
s.executables = ["rpwn", "rpwnctl", "rpwndev"]
|
12
14
|
s.extensions = ["ext/rpwn_setup_notice/extconf.rb"]
|
13
|
-
s.extra_rdoc_files = ["bin/rpwn", "bin/rpwnctl", "bin/rpwndev", "CHANGELOG", "ext/rpwn_setup_notice/extconf.rb", "lib/pwnage/app/cluster_config.rb", "lib/pwnage/app/config.rb", "lib/pwnage/app/database.rb", "lib/pwnage/app/gems.rb", "lib/pwnage/app/main.rb", "lib/pwnage/app/nginx_config.rb", "lib/pwnage/app/scripts.rb", "lib/pwnage/app/svn.rb", "lib/pwnage/base/atomics.rb", "lib/pwnage/base/dirs.rb", "lib/pwnage/base/gems.rb", "lib/pwnage/base/hostname.rb", "lib/pwnage/base/packages.rb", "lib/pwnage/base/process.rb", "lib/pwnage/base/rails.rb", "lib/pwnage/base/startup.rb", "lib/pwnage/base.rb", "lib/pwnage/config/app.rb", "lib/pwnage/config/main.rb", "lib/pwnage/config/paths.rb", "lib/pwnage/config/ports.rb", "lib/pwnage/config/repository.rb", "lib/pwnage/ctl_executor.rb", "lib/pwnage/dev_executor.rb", "lib/pwnage/executor.rb", "lib/pwnage/scaffolds/config.rb", "lib/pwnage/scaffolds/dir_permissions.rb", "lib/pwnage/scaffolds/dirs.rb", "lib/pwnage/scaffolds/gems.rb", "lib/pwnage/scaffolds/hook_daemon.rb", "lib/pwnage/scaffolds/hook_dyndns.rb", "lib/pwnage/scaffolds/mysql_config.rb", "lib/pwnage/scaffolds/packages.rb", "lib/pwnage/scaffolds/rubygems.rb", "lib/pwnage/scaffolds/sshd.rb", "lib/pwnage/util/kill_process_set.rb", "lib/pwnage/util/main.rb", "lib/rails_pwnerer.rb", "LICENSE", "README"]
|
14
|
-
s.files = ["bin/rpwn", "bin/rpwnctl", "bin/rpwndev", "CHANGELOG", "ext/rpwn_setup_notice/extconf.rb", "lib/pwnage/app/cluster_config.rb", "lib/pwnage/app/config.rb", "lib/pwnage/app/database.rb", "lib/pwnage/app/gems.rb", "lib/pwnage/app/main.rb", "lib/pwnage/app/nginx_config.rb", "lib/pwnage/app/scripts.rb", "lib/pwnage/app/svn.rb", "lib/pwnage/base/atomics.rb", "lib/pwnage/base/dirs.rb", "lib/pwnage/base/gems.rb", "lib/pwnage/base/hostname.rb", "lib/pwnage/base/packages.rb", "lib/pwnage/base/process.rb", "lib/pwnage/base/rails.rb", "lib/pwnage/base/startup.rb", "lib/pwnage/base.rb", "lib/pwnage/config/app.rb", "lib/pwnage/config/main.rb", "lib/pwnage/config/paths.rb", "lib/pwnage/config/ports.rb", "lib/pwnage/config/repository.rb", "lib/pwnage/ctl_executor.rb", "lib/pwnage/dev_executor.rb", "lib/pwnage/executor.rb", "lib/pwnage/scaffolds/config.rb", "lib/pwnage/scaffolds/dir_permissions.rb", "lib/pwnage/scaffolds/dirs.rb", "lib/pwnage/scaffolds/gems.rb", "lib/pwnage/scaffolds/hook_daemon.rb", "lib/pwnage/scaffolds/hook_dyndns.rb", "lib/pwnage/scaffolds/mysql_config.rb", "lib/pwnage/scaffolds/packages.rb", "lib/pwnage/scaffolds/rubygems.rb", "lib/pwnage/scaffolds/sshd.rb", "lib/pwnage/util/kill_process_set.rb", "lib/pwnage/util/main.rb", "lib/rails_pwnerer.rb", "LICENSE", "Manifest", "Rakefile", "README", "RUBYFORGE", "rails_pwnerer.gemspec"]
|
15
|
+
s.extra_rdoc_files = ["bin/rpwn", "bin/rpwnctl", "bin/rpwndev", "CHANGELOG", "ext/rpwn_setup_notice/extconf.rb", "lib/pwnage/app/cluster_config.rb", "lib/pwnage/app/config.rb", "lib/pwnage/app/database.rb", "lib/pwnage/app/gems.rb", "lib/pwnage/app/main.rb", "lib/pwnage/app/nginx_config.rb", "lib/pwnage/app/scripts.rb", "lib/pwnage/app/svn.rb", "lib/pwnage/base/atomics.rb", "lib/pwnage/base/cpus.rb", "lib/pwnage/base/dirs.rb", "lib/pwnage/base/gems.rb", "lib/pwnage/base/hostname.rb", "lib/pwnage/base/packages.rb", "lib/pwnage/base/process.rb", "lib/pwnage/base/rails.rb", "lib/pwnage/base/startup.rb", "lib/pwnage/base.rb", "lib/pwnage/config/app.rb", "lib/pwnage/config/main.rb", "lib/pwnage/config/paths.rb", "lib/pwnage/config/ports.rb", "lib/pwnage/config/repository.rb", "lib/pwnage/ctl_executor.rb", "lib/pwnage/dev_executor.rb", "lib/pwnage/executor.rb", "lib/pwnage/scaffolds/config.rb", "lib/pwnage/scaffolds/dir_permissions.rb", "lib/pwnage/scaffolds/dirs.rb", "lib/pwnage/scaffolds/gems.rb", "lib/pwnage/scaffolds/hook_daemon.rb", "lib/pwnage/scaffolds/hook_dyndns.rb", "lib/pwnage/scaffolds/mysql_config.rb", "lib/pwnage/scaffolds/packages.rb", "lib/pwnage/scaffolds/rubygems.rb", "lib/pwnage/scaffolds/sshd.rb", "lib/pwnage/util/kill_process_set.rb", "lib/pwnage/util/main.rb", "lib/rails_pwnerer.rb", "LICENSE", "README"]
|
16
|
+
s.files = ["bin/rpwn", "bin/rpwnctl", "bin/rpwndev", "CHANGELOG", "ext/rpwn_setup_notice/extconf.rb", "lib/pwnage/app/cluster_config.rb", "lib/pwnage/app/config.rb", "lib/pwnage/app/database.rb", "lib/pwnage/app/gems.rb", "lib/pwnage/app/main.rb", "lib/pwnage/app/nginx_config.rb", "lib/pwnage/app/scripts.rb", "lib/pwnage/app/svn.rb", "lib/pwnage/base/atomics.rb", "lib/pwnage/base/cpus.rb", "lib/pwnage/base/dirs.rb", "lib/pwnage/base/gems.rb", "lib/pwnage/base/hostname.rb", "lib/pwnage/base/packages.rb", "lib/pwnage/base/process.rb", "lib/pwnage/base/rails.rb", "lib/pwnage/base/startup.rb", "lib/pwnage/base.rb", "lib/pwnage/config/app.rb", "lib/pwnage/config/main.rb", "lib/pwnage/config/paths.rb", "lib/pwnage/config/ports.rb", "lib/pwnage/config/repository.rb", "lib/pwnage/ctl_executor.rb", "lib/pwnage/dev_executor.rb", "lib/pwnage/executor.rb", "lib/pwnage/scaffolds/config.rb", "lib/pwnage/scaffolds/dir_permissions.rb", "lib/pwnage/scaffolds/dirs.rb", "lib/pwnage/scaffolds/gems.rb", "lib/pwnage/scaffolds/hook_daemon.rb", "lib/pwnage/scaffolds/hook_dyndns.rb", "lib/pwnage/scaffolds/mysql_config.rb", "lib/pwnage/scaffolds/packages.rb", "lib/pwnage/scaffolds/rubygems.rb", "lib/pwnage/scaffolds/sshd.rb", "lib/pwnage/util/kill_process_set.rb", "lib/pwnage/util/main.rb", "lib/rails_pwnerer.rb", "LICENSE", "Manifest", "Rakefile", "README", "RUBYFORGE", "rails_pwnerer.gemspec"]
|
15
17
|
s.has_rdoc = true
|
16
18
|
s.homepage = %q{http://www.costan.us/rails_pwnage}
|
17
19
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rails_pwnerer", "--main", "README"]
|
18
20
|
s.require_paths = ["lib", "ext"]
|
19
21
|
s.rubyforge_project = %q{rails-pwnage}
|
20
|
-
s.rubygems_version = %q{1.
|
22
|
+
s.rubygems_version = %q{1.3.1}
|
21
23
|
s.summary = %q{Rails deployment tool/hack.}
|
22
24
|
|
23
25
|
if s.respond_to? :specification_version then
|
24
26
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
27
|
s.specification_version = 2
|
26
28
|
|
27
|
-
if
|
29
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
30
|
s.add_development_dependency(%q<echoe>, [">= 0"])
|
29
31
|
else
|
30
32
|
s.add_dependency(%q<echoe>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pwnerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-31 00:00:00 -05:00
|
13
13
|
default_executable: bin/rpwn
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -45,6 +45,7 @@ extra_rdoc_files:
|
|
45
45
|
- lib/pwnage/app/scripts.rb
|
46
46
|
- lib/pwnage/app/svn.rb
|
47
47
|
- lib/pwnage/base/atomics.rb
|
48
|
+
- lib/pwnage/base/cpus.rb
|
48
49
|
- lib/pwnage/base/dirs.rb
|
49
50
|
- lib/pwnage/base/gems.rb
|
50
51
|
- lib/pwnage/base/hostname.rb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- lib/pwnage/app/scripts.rb
|
92
93
|
- lib/pwnage/app/svn.rb
|
93
94
|
- lib/pwnage/base/atomics.rb
|
95
|
+
- lib/pwnage/base/cpus.rb
|
94
96
|
- lib/pwnage/base/dirs.rb
|
95
97
|
- lib/pwnage/base/gems.rb
|
96
98
|
- lib/pwnage/base/hostname.rb
|
@@ -154,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
156
|
requirements: []
|
155
157
|
|
156
158
|
rubyforge_project: rails-pwnage
|
157
|
-
rubygems_version: 1.
|
159
|
+
rubygems_version: 1.3.1
|
158
160
|
signing_key:
|
159
161
|
specification_version: 2
|
160
162
|
summary: Rails deployment tool/hack.
|