ruby-debug-passenger 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +18 -0
- data/README.md +62 -0
- data/Rakefile +1 -0
- data/lib/ruby-debug-passenger/version.rb +3 -0
- data/lib/ruby-debug-passenger.rb +27 -0
- data/lib/tasks/debug.rake +34 -0
- data/ruby-debug-passenger.gemspec +30 -0
- metadata +59 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2012 Dave James Miller
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# ruby-debug-passenger
|
2
|
+
|
3
|
+
## Background
|
4
|
+
I wanted to use Phusion Passenger as an Apache module (not standalone) but still
|
5
|
+
be able to use the interactive Ruby debugger.
|
6
|
+
|
7
|
+
Thanks to
|
8
|
+
[Adam Meehan](http://duckpunching.com/passenger-mod_rails-for-development-now-with-debugger)
|
9
|
+
I was able to do that, and I decided to make it into a reusable Gem.
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
This is been tested on:
|
13
|
+
|
14
|
+
* Rails 3.2.2
|
15
|
+
* Ruby (MRI) 1.9.2
|
16
|
+
* Ruby Debugger 0.11.6
|
17
|
+
* Phusion Passenger 3.0.11
|
18
|
+
|
19
|
+
It will probably work on other versions, but not on Rails 2.
|
20
|
+
|
21
|
+
It may or may not work on Ruby 1.8.
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
Add this to your `Gemfile` (assuming you are on Ruby 1.9):
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem "ruby-debug19", require: "ruby-debug"
|
28
|
+
gem "ruby-debug-passenger"
|
29
|
+
```
|
30
|
+
|
31
|
+
Or if you're using Ruby 1.8 you can try the following, but it hasn't been tested!
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem "ruby-debug"
|
35
|
+
gem "ruby-debug-passenger"
|
36
|
+
```
|
37
|
+
|
38
|
+
Then run `bundle install` to install it.
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
Add `debugger` anywhere in your Ruby code that you want to invoke the debugger.
|
42
|
+
(Or in an ERB template add `<% debugger %>`.)
|
43
|
+
|
44
|
+
Run `rake debug` to restart Phusion Passenger and connect to the debugger. (You
|
45
|
+
will be prompted to reload the app in your browser.)
|
46
|
+
|
47
|
+
## Suggested configuration
|
48
|
+
I recommend putting this in your `~/.rdebugrc`:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
set autolist
|
52
|
+
set autoeval
|
53
|
+
set autoreload
|
54
|
+
```
|
55
|
+
|
56
|
+
## Recommended reading
|
57
|
+
* [ruby-debug documentation](http://bashdb.sourceforge.net/ruby-debug.html)
|
58
|
+
* [RailsCast #54](http://railscasts.com/episodes/54-debugging-with-ruby-debug)
|
59
|
+
(the setup steps are out of date, but it shows why ruby-debug can be useful)
|
60
|
+
|
61
|
+
## License
|
62
|
+
MIT License - see `LICENSE.txt`.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "ruby-debug-passenger/version"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module RubyDebugPassenger
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
|
7
|
+
# Initializer
|
8
|
+
initializer "ruby-debug-passenger" do
|
9
|
+
# When Passenger starts the app, this checks if debug.txt exists, and if
|
10
|
+
# so it waits for the debugger to connect before continuing. It will only
|
11
|
+
# ever run in the development environment (for safety more than anything
|
12
|
+
# else).
|
13
|
+
if Rails.env.development? && File.exists?(File.join(Rails.root, 'tmp', 'debug.txt'))
|
14
|
+
require 'ruby-debug'
|
15
|
+
File.delete(File.join(Rails.root, 'tmp', 'debug.txt'))
|
16
|
+
Debugger.wait_connection = true
|
17
|
+
Debugger.start_remote
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Rake task
|
22
|
+
rake_tasks do
|
23
|
+
load "tasks/debug.rake"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
desc "Restart the app with debugging enabled, then launch the debugger"
|
2
|
+
task :debug do
|
3
|
+
|
4
|
+
require 'ruby-debug'
|
5
|
+
|
6
|
+
# This instructs the app to wait for the debugger to connect after loading
|
7
|
+
# See config/environments/development.rb
|
8
|
+
FileUtils.touch(File.join(Rails.root, 'tmp', 'debug.txt'))
|
9
|
+
|
10
|
+
# Instruct Phusion Passenger to restart the app
|
11
|
+
FileUtils.touch(File.join(Rails.root, 'tmp', 'restart.txt'))
|
12
|
+
|
13
|
+
# Wait for it to restart (requires the user to load a page)
|
14
|
+
puts "Waiting for restart (please reload the app in your web browser)..."
|
15
|
+
begin
|
16
|
+
while File.exists?(File.join(Rails.root, 'tmp', 'debug.txt'))
|
17
|
+
sleep 0.5
|
18
|
+
end
|
19
|
+
sleep 1
|
20
|
+
rescue Interrupt
|
21
|
+
File.delete(File.join(Rails.root, 'tmp', 'debug.txt'))
|
22
|
+
puts "\rCancelled."
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
|
26
|
+
puts "Loading debugger..."
|
27
|
+
begin
|
28
|
+
Debugger.start_client
|
29
|
+
rescue Interrupt
|
30
|
+
# Clear the "^C" that is displayed when you press Ctrl-C
|
31
|
+
puts "\r\e[0KDisconnected."
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ruby-debug-passenger/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ruby-debug-passenger"
|
7
|
+
s.version = RubyDebugPassenger::VERSION
|
8
|
+
s.authors = ["Dave James Miller"]
|
9
|
+
s.email = ["dave@davejamesmiller.com"]
|
10
|
+
s.homepage = "https://github.com/davejamesmiller/ruby-debug-passenger"
|
11
|
+
s.summary = %q{Adds a 'rake debug' task to Rails to restart Phusion Passenger with a debugger connected}
|
12
|
+
s.description = <<-EOF
|
13
|
+
Adds an initializer that loads 'ruby-debug' and starts the debugger, and a
|
14
|
+
'rake debug' task that tells Phusion Passenger to restart with debugging
|
15
|
+
enabled. This makes it possible to do interactive debugging when using the
|
16
|
+
Phusion Passenger Apache module - it does not require the standalone server.
|
17
|
+
EOF
|
18
|
+
s.license = 'MIT'
|
19
|
+
|
20
|
+
s.rubyforge_project = "ruby-debug-passenger"
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
|
27
|
+
# specify any dependencies here; for example:
|
28
|
+
# s.add_development_dependency "rspec"
|
29
|
+
# s.add_runtime_dependency "rest-client"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-debug-passenger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dave James Miller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-11 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! " Adds an initializer that loads 'ruby-debug' and starts the debugger,
|
15
|
+
and a\n 'rake debug' task that tells Phusion Passenger to restart with debugging\n
|
16
|
+
\ enabled. This makes it possible to do interactive debugging when using the\n
|
17
|
+
\ Phusion Passenger Apache module - it does not require the standalone server.\n"
|
18
|
+
email:
|
19
|
+
- dave@davejamesmiller.com
|
20
|
+
executables: []
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- .gitignore
|
25
|
+
- Gemfile
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- lib/ruby-debug-passenger.rb
|
30
|
+
- lib/ruby-debug-passenger/version.rb
|
31
|
+
- lib/tasks/debug.rake
|
32
|
+
- ruby-debug-passenger.gemspec
|
33
|
+
homepage: https://github.com/davejamesmiller/ruby-debug-passenger
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project: ruby-debug-passenger
|
54
|
+
rubygems_version: 1.8.10
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Adds a 'rake debug' task to Rails to restart Phusion Passenger with a debugger
|
58
|
+
connected
|
59
|
+
test_files: []
|