rails_pwnerer 0.5.5 → 0.5.6

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.5.6. Replaced mongrel_cluster startup script with our own. Now mongrels survive reboots.
2
+
1
3
  v0.5.5. Stronger database passwords, better mySQL configuration.
2
4
 
3
5
  v0.5.4. Bugfix release: the manifest was busted in 0.5.3.
data/Manifest CHANGED
@@ -1,4 +1,5 @@
1
1
  bin/rpwn
2
+ bin/rpwnctl
2
3
  bin/rpwndev
3
4
  CHANGELOG
4
5
  lib/pwnage/app/cluster_config.rb
@@ -21,13 +22,14 @@ lib/pwnage/config/main.rb
21
22
  lib/pwnage/config/paths.rb
22
23
  lib/pwnage/config/ports.rb
23
24
  lib/pwnage/config/repository.rb
25
+ lib/pwnage/ctl_executor.rb
24
26
  lib/pwnage/dev_executor.rb
25
27
  lib/pwnage/executor.rb
26
28
  lib/pwnage/scaffolds/config.rb
27
29
  lib/pwnage/scaffolds/dirs.rb
28
30
  lib/pwnage/scaffolds/gems.rb
31
+ lib/pwnage/scaffolds/hook_daemon.rb
29
32
  lib/pwnage/scaffolds/hook_dyndns.rb
30
- lib/pwnage/scaffolds/hook_mongrels.rb
31
33
  lib/pwnage/scaffolds/mysql_config.rb
32
34
  lib/pwnage/scaffolds/packages.rb
33
35
  lib/pwnage/scaffolds/rubygems.rb
data/bin/rpwnctl ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'rails_pwnage'
4
+
5
+ RailsPwnage::CtlExecutor.new.run ARGV
@@ -43,11 +43,9 @@ class RailsPwnage::App::ClusterConfig
43
43
 
44
44
  Dir.chdir(app_path) do
45
45
  # create the mongrel_cluster configuration
46
- system "mongrel_rails cluster::configure -e production -N #{mongrels} -p #{first_port} -a 127.0.0.1 -c #{app_path} --user #{pwnerer_user} --group #{pwnerer_group}"
47
-
48
- # copy the configuration to the launch directory
49
- launch_config = File.join RailsPwnage::Config.path_to(:mongrel_configs), "#{app_name}.#{instance_name}.yml"
50
- FileUtils.cp 'config/mongrel_cluster.yml', launch_config
46
+ Kernel.system("mongrel_rails cluster::configure -e production" +
47
+ " -N #{mongrels} -p #{first_port} -a 127.0.0.1 -c #{app_path}" +
48
+ " --user #{pwnerer_user} --group #{pwnerer_group}")
51
49
  end
52
50
  end
53
51
 
@@ -73,17 +71,25 @@ class RailsPwnage::App::ClusterConfig
73
71
  pid = File.open(fname, 'r') { |f| f.read.strip! }
74
72
  # avoid killing innocent victims
75
73
  if pinfo[pid].nil? or patterns.all? { |pattern| pinfo[pid][:cmdline].index pattern }
74
+ print "Killing #{pid}: #{pinfo[pid][:cmdline]}\n"
76
75
  Process.kill 'TERM', pid.to_i
77
76
  end
78
77
  rescue
79
78
  # just in case the file gets wiped before we see it
80
79
  end
80
+ begin
81
+ print "Deleting #{fname}\n"
82
+ File.delete fname if File.exists? fname
83
+ rescue
84
+ # prevents crashing if the file is wiped after we call exists?
85
+ end
81
86
  end
82
87
 
83
88
  # Phase 2: look through the process table and kill anything that looks good
84
89
  pinfo = process_info()
85
90
  pinfo.each do |pid, info|
86
91
  next unless patterns.all? { |pattern| info[:cmdline].index pattern }
92
+ print "Killing #{pid}: #{pinfo[pid][:cmdline]}\n"
87
93
  Process.kill 'TERM', pid.to_i
88
94
  end
89
95
  end
@@ -95,7 +101,7 @@ class RailsPwnage::App::ClusterConfig
95
101
  return unless app_config and File.exists? app_config[:app_path]
96
102
 
97
103
  Dir.chdir app_config[:app_path] do
98
- system 'mongrel_rails cluster::stop'
104
+ Kernel.system 'mongrel_rails cluster::stop'
99
105
  end
100
106
  sleep 0.5
101
107
  kill_stray_mongrels app_name, instance_name
@@ -116,7 +122,7 @@ class RailsPwnage::App::ClusterConfig
116
122
  end
117
123
 
118
124
  Dir.chdir app_config[:app_path] do
119
- system 'mongrel_rails cluster::start'
125
+ Kernel.system 'mongrel_rails cluster::start'
120
126
  end
121
127
  end
122
128
 
@@ -16,9 +16,8 @@ module RailsPwnage::Base
16
16
  end
17
17
 
18
18
  # hooks a script into the boot sequence
19
- def hook_boot_script(script_location)
19
+ def hook_boot_script(script_location, script_name = File.basename(script_location))
20
20
  # copy the script to /etc/init.d and chmod +x
21
- script_name = File.basename script_location
22
21
  target_script = path_to_boot_script script_name
23
22
  FileUtils.cp script_location, target_script
24
23
  File.chmod 0755, target_script
@@ -0,0 +1,19 @@
1
+ class RailsPwnage::CtlExecutor
2
+ # standalone runner
3
+ def run(args)
4
+ case args[0]
5
+ when 'start'
6
+ RailsPwnage::App::ClusterConfig.new.control_all :start
7
+ when 'stop'
8
+ RailsPwnage::App::ClusterConfig.new.control_all :stop
9
+ when 'restart'
10
+ RailsPwnage::App::ClusterConfig.new.control_all :stop
11
+ RailsPwnage::App::ClusterConfig.new.control_all :start
12
+ when 'reload'
13
+ RailsPwnage::App::ClusterConfig.new.control_all :stop
14
+ RailsPwnage::App::ClusterConfig.new.control_all :start
15
+ else
16
+ print "Unrecognized command #{args[0]}\n"
17
+ end
18
+ end
19
+ end
@@ -14,8 +14,8 @@ class RailsPwnage::Executor
14
14
  Dirs.go
15
15
  when 'gems'
16
16
  Gems.go
17
- when 'mongrels'
18
- HookMongrels.go
17
+ when 'daemon'
18
+ HookDaemon.go
19
19
  when 'mysql'
20
20
  MysqlConfig.go
21
21
  when 'packages'
@@ -35,7 +35,7 @@ class RailsPwnage::Executor
35
35
  Dirs.go
36
36
  Config.go
37
37
  MysqlConfig.go
38
- HookMongrels.go
38
+ HookDaemon.go
39
39
  end
40
40
 
41
41
  when 'install', 'micro'
@@ -0,0 +1,26 @@
1
+ # sets up rpwnctl (controlling the yet-to-be-written daemon) to startup at boot time
2
+
3
+ class RailsPwnage::Scaffolds::HookDaemon
4
+ include RailsPwnage::Base
5
+
6
+ # compute the path to mongrel_cluster
7
+ def path_to_gem
8
+ # TODO: use the rubygems API instead of this hack
9
+
10
+ # look for lib/rails_pwnage.rb in our gem
11
+ output = `gem which 'rails_pwnage'`
12
+ # now lock down the path
13
+ output.split.last.gsub!('lib/rails_pwnage.rb', '')
14
+ end
15
+
16
+ # runner
17
+ def run
18
+ daemon_ctl = self.path_to_gem + 'bin/rpwnctl'
19
+ hook_boot_script daemon_ctl, 'rpwn'
20
+ end
21
+
22
+ # standalone runner
23
+ def self.go
24
+ self.new.run
25
+ end
26
+ end
data/lib/rails_pwnage.rb CHANGED
@@ -29,7 +29,7 @@ require 'pwnage/config/repository.rb'
29
29
  require 'pwnage/scaffolds/config.rb'
30
30
  require 'pwnage/scaffolds/dirs.rb'
31
31
  require 'pwnage/scaffolds/gems.rb'
32
- require 'pwnage/scaffolds/hook_mongrels.rb'
32
+ require 'pwnage/scaffolds/hook_daemon.rb'
33
33
  require 'pwnage/scaffolds/hook_dyndns.rb'
34
34
  require 'pwnage/scaffolds/mysql_config.rb'
35
35
  require 'pwnage/scaffolds/packages.rb'
@@ -43,5 +43,6 @@ require 'pwnage/app/gems.rb'
43
43
  require 'pwnage/app/nginx_config.rb'
44
44
  require 'pwnage/app/svn.rb'
45
45
 
46
+ require 'pwnage/ctl_executor.rb'
46
47
  require 'pwnage/dev_executor.rb'
47
48
  require 'pwnage/executor.rb'
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Rails_pwnerer-0.5.5
2
+ # Gem::Specification for Rails_pwnerer-0.5.6
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.5.5
8
+ version: 0.5.6
9
9
  platform: ruby
10
10
  authors:
11
11
  - Victor Costan
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-08-16 00:00:00 -04:00
15
+ date: 2008-08-17 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -29,11 +29,13 @@ description: Rails deployment tool/hack.
29
29
  email: victor@costan.us
30
30
  executables:
31
31
  - rpwn
32
+ - rpwnctl
32
33
  - rpwndev
33
34
  extensions: []
34
35
 
35
36
  extra_rdoc_files:
36
37
  - bin/rpwn
38
+ - bin/rpwnctl
37
39
  - bin/rpwndev
38
40
  - CHANGELOG
39
41
  - lib/pwnage/app/cluster_config.rb
@@ -56,13 +58,14 @@ extra_rdoc_files:
56
58
  - lib/pwnage/config/paths.rb
57
59
  - lib/pwnage/config/ports.rb
58
60
  - lib/pwnage/config/repository.rb
61
+ - lib/pwnage/ctl_executor.rb
59
62
  - lib/pwnage/dev_executor.rb
60
63
  - lib/pwnage/executor.rb
61
64
  - lib/pwnage/scaffolds/config.rb
62
65
  - lib/pwnage/scaffolds/dirs.rb
63
66
  - lib/pwnage/scaffolds/gems.rb
67
+ - lib/pwnage/scaffolds/hook_daemon.rb
64
68
  - lib/pwnage/scaffolds/hook_dyndns.rb
65
- - lib/pwnage/scaffolds/hook_mongrels.rb
66
69
  - lib/pwnage/scaffolds/mysql_config.rb
67
70
  - lib/pwnage/scaffolds/packages.rb
68
71
  - lib/pwnage/scaffolds/rubygems.rb
@@ -71,6 +74,7 @@ extra_rdoc_files:
71
74
  - README
72
75
  files:
73
76
  - bin/rpwn
77
+ - bin/rpwnctl
74
78
  - bin/rpwndev
75
79
  - CHANGELOG
76
80
  - lib/pwnage/app/cluster_config.rb
@@ -93,13 +97,14 @@ files:
93
97
  - lib/pwnage/config/paths.rb
94
98
  - lib/pwnage/config/ports.rb
95
99
  - lib/pwnage/config/repository.rb
100
+ - lib/pwnage/ctl_executor.rb
96
101
  - lib/pwnage/dev_executor.rb
97
102
  - lib/pwnage/executor.rb
98
103
  - lib/pwnage/scaffolds/config.rb
99
104
  - lib/pwnage/scaffolds/dirs.rb
100
105
  - lib/pwnage/scaffolds/gems.rb
106
+ - lib/pwnage/scaffolds/hook_daemon.rb
101
107
  - lib/pwnage/scaffolds/hook_dyndns.rb
102
- - lib/pwnage/scaffolds/hook_mongrels.rb
103
108
  - lib/pwnage/scaffolds/mysql_config.rb
104
109
  - lib/pwnage/scaffolds/packages.rb
105
110
  - lib/pwnage/scaffolds/rubygems.rb
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.5.5
4
+ version: 0.5.6
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-08-16 00:00:00 -04:00
12
+ date: 2008-08-17 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -26,11 +26,13 @@ description: Rails deployment tool/hack.
26
26
  email: victor@costan.us
27
27
  executables:
28
28
  - rpwn
29
+ - rpwnctl
29
30
  - rpwndev
30
31
  extensions: []
31
32
 
32
33
  extra_rdoc_files:
33
34
  - bin/rpwn
35
+ - bin/rpwnctl
34
36
  - bin/rpwndev
35
37
  - CHANGELOG
36
38
  - lib/pwnage/app/cluster_config.rb
@@ -53,13 +55,14 @@ extra_rdoc_files:
53
55
  - lib/pwnage/config/paths.rb
54
56
  - lib/pwnage/config/ports.rb
55
57
  - lib/pwnage/config/repository.rb
58
+ - lib/pwnage/ctl_executor.rb
56
59
  - lib/pwnage/dev_executor.rb
57
60
  - lib/pwnage/executor.rb
58
61
  - lib/pwnage/scaffolds/config.rb
59
62
  - lib/pwnage/scaffolds/dirs.rb
60
63
  - lib/pwnage/scaffolds/gems.rb
64
+ - lib/pwnage/scaffolds/hook_daemon.rb
61
65
  - lib/pwnage/scaffolds/hook_dyndns.rb
62
- - lib/pwnage/scaffolds/hook_mongrels.rb
63
66
  - lib/pwnage/scaffolds/mysql_config.rb
64
67
  - lib/pwnage/scaffolds/packages.rb
65
68
  - lib/pwnage/scaffolds/rubygems.rb
@@ -68,6 +71,7 @@ extra_rdoc_files:
68
71
  - README
69
72
  files:
70
73
  - bin/rpwn
74
+ - bin/rpwnctl
71
75
  - bin/rpwndev
72
76
  - CHANGELOG
73
77
  - lib/pwnage/app/cluster_config.rb
@@ -90,13 +94,14 @@ files:
90
94
  - lib/pwnage/config/paths.rb
91
95
  - lib/pwnage/config/ports.rb
92
96
  - lib/pwnage/config/repository.rb
97
+ - lib/pwnage/ctl_executor.rb
93
98
  - lib/pwnage/dev_executor.rb
94
99
  - lib/pwnage/executor.rb
95
100
  - lib/pwnage/scaffolds/config.rb
96
101
  - lib/pwnage/scaffolds/dirs.rb
97
102
  - lib/pwnage/scaffolds/gems.rb
103
+ - lib/pwnage/scaffolds/hook_daemon.rb
98
104
  - lib/pwnage/scaffolds/hook_dyndns.rb
99
- - lib/pwnage/scaffolds/hook_mongrels.rb
100
105
  - lib/pwnage/scaffolds/mysql_config.rb
101
106
  - lib/pwnage/scaffolds/packages.rb
102
107
  - lib/pwnage/scaffolds/rubygems.rb
@@ -1,38 +0,0 @@
1
- # sets up mongrel_cluster to startup at boot time
2
-
3
- class RailsPwnage::Scaffolds::HookMongrels
4
- include RailsPwnage::Base
5
-
6
- # compute the path to mongrel_cluster
7
- def path_to_gem
8
- # TODO: use the rubygems API instead of this hack
9
-
10
- # look for lib/init.rb in mongrel_cluster (hopefully this won't break)
11
- output = `gem which 'mongrel_cluster/init'`
12
- # now lock down the path
13
- output.split.last.gsub!('lib/mongrel_cluster/init.rb', '')
14
- end
15
-
16
- # add mongrel_cluster to the startup
17
- def hook_bootscript
18
- mongrel_script = self.path_to_gem + 'resources/mongrel_cluster'
19
- hook_boot_script mongrel_script
20
- end
21
-
22
- # build the configuration
23
- def make_config
24
- config_dir = RailsPwnage::Config.path_to(:mongrel_configs)
25
- Dir.mkdir config_dir unless File.exists? config_dir
26
- end
27
-
28
- # runner
29
- def run
30
- make_config
31
- hook_bootscript
32
- end
33
-
34
- # standalone runner
35
- def self.go
36
- self.new.run
37
- end
38
- end