guard-foreman 0.0.1 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/guard-foreman.gemspec +2 -1
- data/lib/guard/foreman.rb +37 -22
- data/lib/guard/foreman/templates/Guardfile +1 -1
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40b508de306cc41dfeb333c1c413fe8230d61b1f
|
4
|
+
data.tar.gz: 41e889b8837f3b7fffecbf0b94466a5cc0401aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa27b477be2bf5bd5eb8cd85df96389b9c07e39c21ab493c6c3cf516b967985e2b440e64dbb5f0def13dd7d4f6d5b8bd3d6719a11d7cf32e827a2ba87dbbf25
|
7
|
+
data.tar.gz: 1bcd21e8b2c9286b80d2fb2457ca0c22c24d84d2891f6e146e16d49111ecee458b138cd41545ec2d74c639e6e4a2760a97a92119cbb755d6283a590c77b0e535
|
data/README.md
CHANGED
data/guard-foreman.gemspec
CHANGED
@@ -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.
|
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
|
data/lib/guard/foreman.rb
CHANGED
@@ -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
|
32
|
-
cmd
|
33
|
-
cmd
|
34
|
-
cmd
|
35
|
-
cmd
|
36
|
-
cmd
|
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 = ::
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
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
|
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.
|
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-
|
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.
|
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:
|