guard-passenger 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,6 @@
1
1
  = Guard::Passenger
2
2
 
3
- Passenger guard allows to automatically & intelligently restart passenger when needed.
4
- This is particularly useful if you use passenger in development.
5
-
3
+ Guard::Passenger is the useful development server solution. The guard automatically starts passenger and intelligently restarts the server when needed.
6
4
 
7
5
  == Install
8
6
 
@@ -26,7 +24,7 @@ Please read {guard usage doc}[http://github.com/guard/guard#readme]
26
24
 
27
25
  == Guardfile
28
26
 
29
- Passenger guard can be really be adapated to all kind of rack project with passenger.
27
+ Passenger guard can be really be adapted to all kind of rack project with passenger.
30
28
  Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
31
29
 
32
30
  === Standard rails app
@@ -50,11 +48,12 @@ By default passenger standalone is deactivated and port is set to 3000.
50
48
 
51
49
  Guard::Passenger accepts some options for configuration.
52
50
 
53
- # :standalone boolean run passenger standalone (default: false)
54
- # :port integer using the given port (default: 3000)
55
- # :env string framework environment (default: development)
51
+ # :standalone boolean run passenger standalone (default: true)
52
+ # :port integer using the given port (default: 3000)
53
+ # :env string framework environment (default: development)
54
+ # :touch string path to check if restart was successful (default: /) (false = off)
56
55
 
57
- guard 'passenger', :standalone => true, :port => 3001, :env => 'production' do
56
+ guard 'passenger', :standalone => false, :port => 3001, :env => 'production', :touch => '/users/all' do
58
57
  end
59
58
 
60
59
  == Development
@@ -6,8 +6,9 @@ module Guard
6
6
  class Passenger < Guard
7
7
 
8
8
  autoload :Runner, 'guard/passenger/runner'
9
+ autoload :Toucher, 'guard/passenger/toucher'
9
10
 
10
- attr_reader :port, :env
11
+ attr_reader :port, :env, :touch
11
12
 
12
13
  def standalone?
13
14
  @standalone
@@ -19,9 +20,10 @@ module Guard
19
20
 
20
21
  def initialize(watchers = [], options = {})
21
22
  super
22
- @standalone = options[:standalone].nil? ? false : options[:standalone]
23
+ @standalone = options[:standalone].nil? ? true : options[:standalone]
23
24
  @port = options[:port].nil? ? 3000 : options[:port]
24
25
  @env = options[:env].nil? ? 'development' : options[:env]
26
+ @touch = options[:touch].nil? ? '/' : options[:touch]
25
27
  end
26
28
 
27
29
  # Call once when guard starts
@@ -45,7 +47,7 @@ module Guard
45
47
 
46
48
  # Call with Ctrl-Z signal
47
49
  def reload
48
- Runner.restart_passenger
50
+ restart_and_touch
49
51
  end
50
52
 
51
53
  # Call with Ctrl-/ signal
@@ -55,7 +57,26 @@ module Guard
55
57
 
56
58
  # Call on file(s) modifications
57
59
  def run_on_change(paths)
58
- Runner.restart_passenger
60
+ restart_and_touch
59
61
  end
62
+
63
+ private
64
+ def restart_and_touch
65
+ if Runner.restart_passenger & touch_url
66
+ UI.info 'Successfully restarted passenger'
67
+ true
68
+ else
69
+ UI.error 'Restarting passenger failed'
70
+ false
71
+ end
72
+ end
73
+
74
+ def touch_url
75
+ if touch
76
+ Toucher.touch('localhost', port, touch)
77
+ else
78
+ true
79
+ end
80
+ end
60
81
  end
61
82
  end
@@ -4,14 +4,7 @@ module Guard
4
4
  class << self
5
5
 
6
6
  def restart_passenger
7
- result = system 'touch tmp/restart.txt'
8
- if result
9
- UI.info 'Successfully restarted passenger'
10
- else
11
- UI.error 'Restarting passenger failed'
12
- end
13
-
14
- result
7
+ system 'touch tmp/restart.txt'
15
8
  end
16
9
 
17
10
  def start_passenger(port, environment)
@@ -0,0 +1,23 @@
1
+ require 'net/http'
2
+
3
+ module Guard
4
+ class Passenger
5
+ module Toucher
6
+ class << self
7
+
8
+ # try recieve header from given url (e.g. http://localhost:3000/) and return false if response status is 500
9
+ def touch(host, port, path)
10
+ begin
11
+ response = nil;
12
+ Net::HTTP.start(host, port) do |http|
13
+ response = http.head(path)
14
+ end
15
+ response['status'].to_i != 500
16
+ rescue
17
+ false
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module PassengerVersion
3
- VERSION = '0.0.6'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-passenger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 6
10
- version: 0.0.6
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Fabio Kuhn
@@ -62,6 +62,7 @@ extra_rdoc_files: []
62
62
  files:
63
63
  - lib/guard/passenger/runner.rb
64
64
  - lib/guard/passenger/templates/Guardfile
65
+ - lib/guard/passenger/toucher.rb
65
66
  - lib/guard/passenger/version.rb
66
67
  - lib/guard/passenger.rb
67
68
  - LICENSE