rails_pwnerer 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.6.4. Added configuration variable for the environment. Switched to a more determinstic config update model.
2
+
1
3
  v0.6.3. Bugfix: scaffolding "forgot" to install database gems.
2
4
 
3
5
  v0.6.2. Added port-based filterning, so there's no need for a CNAME for every app.
data/README CHANGED
@@ -45,7 +45,7 @@ Workaround:
45
45
 
46
46
  a) Find the path to the gems: gem environment gemdir (e.g. /var/lib/gems/1.8/gems/)
47
47
  b) run bin/rpwn from there:
48
- sudo /var/lib/gems/1.8/bin/rails_pwnerer scaffold
48
+ sudo /var/lib/gems/1.8/bin/rpwn scaffold
49
49
 
50
50
  After you scaffold, you'll get good rubygems which put rpwn in your path.
51
51
 
@@ -70,6 +70,7 @@ class RailsPwnage::App::ClusterConfig
70
70
  app_path, pwnerer_user = app_config[:app_path], app_config[:pwnerer_user]
71
71
  pwnerer_group = group_for_username(pwnerer_user)
72
72
  frontends, first_port = app_config[:frontends], app_config[:port0]
73
+ environment = app_config[:environment]
73
74
 
74
75
  stop app_name, instance_name
75
76
 
@@ -81,7 +82,7 @@ class RailsPwnage::App::ClusterConfig
81
82
  end
82
83
 
83
84
  static_cmd = "thin start -a 127.0.0.1 -A rails -c #{app_path} -d -u #{pwnerer_user}" +
84
- " -g #{pwnerer_group} -e production "
85
+ " -g #{pwnerer_group} -e #{environment} "
85
86
 
86
87
  # TODO: start the servers simultaneously
87
88
  Dir.chdir app_config[:app_path] do
@@ -4,42 +4,51 @@ require 'yaml'
4
4
  class RailsPwnage::App::Config
5
5
  include RailsPwnage::Base
6
6
 
7
- # allocates room for the application and creates the application configuration database
8
- def alloc(app_name, instance_name)
9
- app_path = File.join(RailsPwnage::Config.path_to(:apps), app_name + '.' + instance_name)
10
- FileUtils.mkpath app_path
11
-
12
- app_db_name = RailsPwnage::Config.app_db_name(app_name, instance_name)
13
- app_db = RailsPwnage::Config.create_db app_db_name
14
-
15
- # default settings
16
-
17
- app_db[:app_path] = app_path
18
- app_db[:backup_path] = File.join(RailsPwnage::Config.path_to(:backups), app_name + '.' + instance_name)
7
+ # fills inexsitent keys with their default values
8
+ # setup: this effectively creates the baseline configuration db
9
+ # update: this adds keys that might have been added in new versions of rpwn
10
+ def populate_defaults(app_name, instance_name, app_db)
11
+ # the path to application backups
12
+ app_db[:backup_path] ||= File.join(RailsPwnage::Config.path_to(:backups), app_name + '.' + instance_name)
19
13
 
20
14
  # the user which will receive the "keys" to the production system
21
- app_db[:pwnerer_user] = 'victor'
15
+ app_db[:pwnerer_user] ||= 'victor'
22
16
  # the number of frontends for the application instance
23
- app_db[:frontends] = 4
17
+ app_db[:frontends] ||= 4
24
18
  # the first internal port for the application instance
25
19
  app_db[:port0] = 0 # will be overwritten during allocation
26
20
  # the name of the database for the application instance
27
- app_db[:db_name] = app_name + '_' + instance_name + '_prod'
21
+ app_db[:db_name] ||= app_name + '_' + instance_name + '_prod'
28
22
  # the datbase user for the given application
29
- app_db[:db_user] = (app_name + '_' + instance_name)[0...16] # mySQL doesn't like long user names
23
+ app_db[:db_user] ||= (app_name + '_' + instance_name)[0...16] # mySQL doesn't like long user names
30
24
  # the password of the database user for the given application
31
- app_db[:db_pass] = (0...16).map { |i| "abcdefghijklmnopqrstuvwxyz"[rand(26),1]}.join
25
+ app_db[:db_pass] ||= (0...16).map { |i| "abcdefghijklmnopqrstuvwxyz"[rand(26),1]}.join
32
26
  # a DNS name for server-based filtering (multiple apps on the same box)
33
- app_db[:dns_name] = ''
27
+ app_db[:dns_name] ||= ''
28
+ # the environment to run the application in
29
+ app_db[:environment] ||= 'production'
34
30
  # a port for server-based filtering (multiple apps on the same box)
35
- app_db[:port] = 80
31
+ app_db[:port] ||= 80
36
32
  # the maximum request size (megabytes) to be accepted by an application
37
- app_db[:max_request_mb] = 48
33
+ app_db[:max_request_mb] ||= 48
38
34
  # comma-separated directories that should be writable by the application user
39
- app_db[:writable_dirs] = ''
35
+ app_db[:writable_dirs] ||= ''
40
36
  # comma-separated gems that should be installed for the application
41
- app_db[:gems] = ''
37
+ app_db[:gems] ||= ''
38
+ end
39
+
40
+ # allocates room for the application and creates the application configuration database
41
+ def alloc(app_name, instance_name)
42
+ app_path = File.join(RailsPwnage::Config.path_to(:apps), app_name + '.' + instance_name)
43
+ FileUtils.mkpath app_path
44
+
45
+ app_db_name = RailsPwnage::Config.app_db_name(app_name, instance_name)
46
+ app_db = RailsPwnage::Config.create_db app_db_name
42
47
 
48
+ # default settings
49
+ app_db[:app_path] = app_path
50
+ populate_defaults app_name, instance_name, app_db
51
+
43
52
  RailsPwnage::Config.flush_db app_db
44
53
  return app_path
45
54
  end
@@ -47,6 +56,8 @@ class RailsPwnage::App::Config
47
56
  # pushes config changes from the application file to the database
48
57
  def update(app_name, instance_name)
49
58
  app_config = RailsPwnage::Config[app_name, instance_name]
59
+ app_config.clear
60
+ populate_defaults app_name, instance_name, app_db
50
61
  Dir.chdir app_config[:app_path] do
51
62
  ["config/rails_pwnerer/.yml", "config/rails_pwnerer/#{instance_name}.yml"].each do |fname|
52
63
  next unless File.exists? fname
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Rails_pwnerer-0.6.3
2
+ # Gem::Specification for Rails_pwnerer-0.6.4
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: rails_pwnerer
7
7
  version: !ruby/object:Gem::Version
8
- version: 0.6.3
8
+ version: 0.6.4
9
9
  platform: ruby
10
10
  authors:
11
11
  - Victor Costan
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-09-07 00:00:00 -04:00
15
+ date: 2008-09-19 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
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.3
4
+ version: 0.6.4
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-09-07 00:00:00 -04:00
12
+ date: 2008-09-19 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency