guard-foreman 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8122ce0888dccef83983172378b2ec71791c0157
4
- data.tar.gz: 23c67c7a07b7d2d13a3d2c100102ccb781edd0b0
3
+ metadata.gz: 40b508de306cc41dfeb333c1c413fe8230d61b1f
4
+ data.tar.gz: 41e889b8837f3b7fffecbf0b94466a5cc0401aad
5
5
  SHA512:
6
- metadata.gz: f6fb2293540ace3c8b172def3f010c16926187b63a479319b22aeeb6c730015a3bea2514169b67a662c5c3d71bdcb063873972aafa33c731cf245d216d2dd702
7
- data.tar.gz: 4634fcfe87ec1aafb88d00ac988f167426ec6450a7cac28673a9fbe7226f535bfdbc738fb0b6553e6eadb59e9de889338bc1fb0f70eae4601feaa7379a39dafa
6
+ metadata.gz: 0fa27b477be2bf5bd5eb8cd85df96389b9c07e39c21ab493c6c3cf516b967985e2b440e64dbb5f0def13dd7d4f6d5b8bd3d6719a11d7cf32e827a2ba87dbbf25
7
+ data.tar.gz: 1bcd21e8b2c9286b80d2fb2457ca0c22c24d84d2891f6e146e16d49111ecee458b138cd41545ec2d74c639e6e4a2760a97a92119cbb755d6283a590c77b0e535
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Guard::Foreman
2
2
 
3
+ This project was originally a fork of [Guard::Unicorn] [gdu], but has since
4
+ diverged significantly.
5
+
3
6
  `Guard::Foreman` automatically restarts Foreman using [Guard] [gu].
4
7
 
5
8
  [gu]: https://github.com/guard/guard
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "guard-foreman"
6
- s.version = "0.0.1"
6
+ s.version = "0.0.4"
7
7
  s.authors = ["Andrei Maxim", "Jonathan Arnett"]
8
8
  s.licenses = ['MIT']
9
9
  s.email = ["jonarnett90@gmail.com"]
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_dependency 'guard', '~> 2.6'
20
+ s.add_dependency 'spoon', '~> 0.0', '>= 0.0.4'
20
21
  end
@@ -1,11 +1,13 @@
1
1
  require 'guard'
2
2
  require 'guard/plugin'
3
+ require 'spoon'
3
4
 
4
5
  module Guard
5
6
  class Foreman < Plugin
6
7
 
7
8
  # Default log location (Rails in mind)
8
9
  DEFAULT_LOG_LOCATION = "log/foreman.log"
10
+ TITLE = "Foreman status"
9
11
 
10
12
  # Initialize a Guard.
11
13
  # @param [Array<Guard::Watcher>] watchers the Guard file watchers
@@ -27,36 +29,37 @@ module Guard
27
29
  # Stop if running
28
30
  stop if @pid
29
31
 
30
- cmd = []
31
- cmd << "foreman start"
32
- cmd << "-c #{@concurrency}" if @concurrency
33
- cmd << "-e #{@env}" if @env
34
- cmd << "-f #{@procfile}" if @procfile
35
- cmd << "-p #{@port}" if @port
36
- cmd << "-d #{@root}" if @root
37
- cmd << "> #{@log_file}"
32
+ cmd = "foreman start"
33
+ cmd += " -c #{@concurrency}" if @concurrency
34
+ cmd += " -e #{@env}" if @env
35
+ cmd += " -f #{@procfile}" if @procfile
36
+ cmd += " -p #{@port}" if @port
37
+ cmd += " -d #{@root}" if @root
38
+ #cmd += " > #{@log_file}" # Disabled for now
38
39
 
39
-
40
- @pid = ::Process.fork do
41
- system "#{cmd.join " "}"
42
- end
40
+ debug "About to run #{cmd}"
41
+ @pid = ::Spoon.spawnp(*cmd.split(" ")) # Spoon is a little weird
43
42
 
44
43
  info "Foreman started."
44
+ debug "Foreman has pid #{@pid}"
45
+ success "Foreman started"
45
46
  end
46
47
 
47
48
  # Called when `stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
48
49
  # @raise [:task_has_failed] when stop has failed
49
50
  def stop
50
- begin
51
- ::Process.kill("QUIT", @pid) if ::Process.getpgid(@pid)
52
-
53
- # foreman won't always shut down right away, so we're waiting for
54
- # the getpgid method to raise an Errno::ESRCH that will tell us
55
- # the process is not longer active.
56
- sleep 1 while ::Process.getpgid(@pid)
51
+ if @pid
52
+ begin
53
+ debug "Asking Foreman to terminate... (#{@pid})"
54
+ ::Process.kill("TERM", @pid)
55
+ debug "Waiting for Foreman to stop..."
56
+ ::Process.waitpid(@pid)
57
+ @pid = nil # Unset @pid
58
+ rescue Errno::ESRCH
59
+ # Don't do anything, the process does not exist
60
+ debug "Could not find Foreman process"
61
+ end
57
62
  info "Foreman stopped."
58
- rescue Errno::ESRCH
59
- # Don't do anything, the process does not exist
60
63
  end
61
64
  end
62
65
 
@@ -65,7 +68,7 @@ module Guard
65
68
  # reloading passenger/spork/bundler/...
66
69
  # @raise [:task_has_failed] when reload has failed
67
70
  def reload
68
- UI.info "Restarting Foreman..."
71
+ info "Restarting Foreman..."
69
72
  stop
70
73
  start
71
74
  end
@@ -101,5 +104,17 @@ module Guard
101
104
  def info(msg)
102
105
  UI.info(msg)
103
106
  end
107
+
108
+ def debug(msg)
109
+ UI.debug(msg)
110
+ end
111
+
112
+ def success(msg)
113
+ ::Guard::Notifier.notify(msg, title: TITLE, image: :success)
114
+ end
115
+
116
+ def failure(msg)
117
+ ::Guard::Notifier.notify(msg, title: TITLE, image: :failure)
118
+ end
104
119
  end
105
120
  end
@@ -7,7 +7,7 @@
7
7
  # * :procfile - an alternate Procfile to use (default is Procfile)
8
8
  # * :port - an alternate port to use (default is 5000)
9
9
  # * :root - an alternate application root
10
- guard :foreman, procfile: 'Procfile.dev' do
10
+ guard :foreman do
11
11
  # Rails example - Watch controllers, models, helpers, lib, and config files
12
12
  watch( /^app\/(controllers|models|helpers)\/.+\.rb$/ )
13
13
  watch( /^lib\/.+\.rb$/ )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Maxim
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-16 00:00:00.000000000 Z
12
+ date: 2014-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -25,6 +25,26 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: spoon
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.0'
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.4
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '0.0'
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.4
28
48
  description: Guard plug-in that allows you to restart Foreman
29
49
  email:
30
50
  - jonarnett90@gmail.com
@@ -60,10 +80,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
80
  version: '0'
61
81
  requirements: []
62
82
  rubyforge_project:
63
- rubygems_version: 2.4.1
83
+ rubygems_version: 2.4.4
64
84
  signing_key:
65
85
  specification_version: 4
66
86
  summary: Guard for Foreman
67
87
  test_files:
68
88
  - test/test_helper.rb
69
- has_rdoc: