guard-goliath 1.0.0
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 +7 -0
- data/.gitignore +7 -0
- data/.rubocop.yml +21 -0
- data/Gemfile +15 -0
- data/LICENSE.md +22 -0
- data/README.md +32 -0
- data/Rakefile +21 -0
- data/guard-goliath.gemspec +28 -0
- data/lib/guard-goliath.rb +1 -0
- data/lib/guard/goliath.rb +51 -0
- data/lib/guard/goliath/runner.rb +96 -0
- data/lib/guard/goliath/templates/Guardfile +5 -0
- data/lib/guard/goliath/version.rb +5 -0
- metadata +169 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2b853ffd49fc3a78a2d5eb26ae95e65bb1607313
|
4
|
+
data.tar.gz: 2b9ae75ebdb750453111a48d83743ad8b12647ef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a28d3c145bd67bc9385f69978f3f9aa4c0cc6b890cc90b39938bf23a9dfffb9b6f6001b96ba3260a9efae5fdac43b4bd8608c659d363b1c1a33d00e6b09d28d
|
7
|
+
data.tar.gz: e7771dd8becfd877785b39cdb0e8a162824137c1ac11cdc5dfcbf63b5669778e14df521ab469aa06e4240f603bb1672fad11c19b8b70448d7b68fd0097e31691
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
Excludes:
|
3
|
+
- vendor/**
|
4
|
+
- bin/**
|
5
|
+
|
6
|
+
LineLength:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
MethodLength:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
ClassLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Documentation:
|
16
|
+
# don't require classes to be documented
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Encoding:
|
20
|
+
# no need to always specify encoding
|
21
|
+
Enabled: false
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "ffi"
|
4
|
+
gem "spoon"
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem "rake"
|
8
|
+
gem "bundler"
|
9
|
+
gem "rack"
|
10
|
+
gem 'growl'
|
11
|
+
gem 'rb-inotify', require: false
|
12
|
+
gem 'rb-fsevent', require: false
|
13
|
+
gem 'rb-fchange', require: false
|
14
|
+
gem 'rubocop'
|
15
|
+
end
|
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Daniel Doubrovkine
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Guard::Goliath
|
2
|
+
===========
|
3
|
+
|
4
|
+
Want to restart your Rack development with *rackup* whilst you work? Now you can!
|
5
|
+
|
6
|
+
guard 'goliath', port: 9000, app_file: 'app.rb' do
|
7
|
+
watch('Gemfile.lock')
|
8
|
+
watch(%r{*.rb})
|
9
|
+
end
|
10
|
+
|
11
|
+
Options
|
12
|
+
-------
|
13
|
+
|
14
|
+
* `:port` is the port number to run on (default `9000`)
|
15
|
+
* `:environment` is the environment to use (default `development`)
|
16
|
+
* `:start_on_start` will start the server when starting Guard (default `true`)
|
17
|
+
* `:force_run` kills any process that's holding open the listen port before attempting to (re)start Rack (default `false`).
|
18
|
+
* `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (default `false`).
|
19
|
+
* `:timeout` waits this number of seconds when restarting the Rack server before reporting there's a problem (default `20`).
|
20
|
+
|
21
|
+
Contributing
|
22
|
+
------------
|
23
|
+
|
24
|
+
Fork the project. Make your feature addition or bug fix with tests. Send a pull request. Bonus points for topic branches.
|
25
|
+
|
26
|
+
Copyright and License
|
27
|
+
---------------------
|
28
|
+
|
29
|
+
MIT License, see [LICENSE](http://github.com/dblock/guard-rack/raw/master/LICENSE.md) for details.
|
30
|
+
|
31
|
+
(c) 2014 [Nikolay Norkin](http://github.com/duderman)
|
32
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
require File.expand_path('../lib/guard/rack/version', __FILE__)
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
|
16
|
+
require 'rainbow/ext/string' unless String.respond_to?(:color)
|
17
|
+
require 'rubocop/rake_task'
|
18
|
+
Rubocop::RakeTask.new(:rubocop)
|
19
|
+
|
20
|
+
task default: [:rubocop]
|
21
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path('../lib/guard/goliath/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Nikolay Norkin"]
|
7
|
+
|
8
|
+
gem.email = ["zduderman@gmail.com"]
|
9
|
+
gem.description = "Automatically reloads your Goliath app on file change using Guard."
|
10
|
+
gem.homepage = "https://github.com/duderman/guard-goliath"
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.license = 'MIT'
|
13
|
+
|
14
|
+
gem.name = "guard-goliath"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.version = Guard::GoliathVersion::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency "guard"
|
20
|
+
gem.add_dependency "ffi"
|
21
|
+
gem.add_dependency "spoon"
|
22
|
+
gem.add_dependency "rb-inotify"
|
23
|
+
gem.add_dependency "libnotify"
|
24
|
+
|
25
|
+
gem.add_development_dependency "rake"
|
26
|
+
gem.add_development_dependency "bundler"
|
27
|
+
gem.add_development_dependency "rack"
|
28
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'guard/goliath'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/goliath/runner'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
module Guard
|
7
|
+
class Goliath < ::Guard::Guard
|
8
|
+
attr_reader :options, :runner
|
9
|
+
|
10
|
+
DEFAULT_OPTIONS = {
|
11
|
+
port: 9000,
|
12
|
+
environment: 'development',
|
13
|
+
start_on_start: true,
|
14
|
+
force_run: false,
|
15
|
+
timeout: 20,
|
16
|
+
app_file: 'app.rb'
|
17
|
+
}
|
18
|
+
|
19
|
+
def initialize(watchers = [], options = {})
|
20
|
+
super
|
21
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
22
|
+
@runner = ::Guard::GoliathRunner.new(@options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
UI.info "Guard::Goliath will now restart your app on port #{options[:port]} using #{options[:environment]} environment."
|
27
|
+
reload if options[:start_on_start]
|
28
|
+
end
|
29
|
+
|
30
|
+
def reload
|
31
|
+
UI.info 'Restarting App...'
|
32
|
+
Notifier.notify("App restarting on port #{options[:port]} in #{options[:environment]} environment...", title: 'Restarting App...', image: :pending)
|
33
|
+
if runner.restart
|
34
|
+
UI.info "App restarted, pid #{runner.pid}"
|
35
|
+
Notifier.notify("App restarted on port #{options[:port]}.", title: 'App restarted!', image: :success)
|
36
|
+
else
|
37
|
+
UI.info 'App NOT restarted, check your log files.'
|
38
|
+
Notifier.notify('App NOT restarted, check your log files.', title: 'App NOT restarted!', image: :failed)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def stop
|
43
|
+
Notifier.notify('Until next time...', title: 'App shutting down.', image: :pending)
|
44
|
+
runner.stop
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_on_changes(paths)
|
48
|
+
reload
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'timeout'
|
3
|
+
require 'spoon'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class GoliathRunner
|
7
|
+
attr_reader :options, :pid
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def start
|
14
|
+
kill_unmanaged_pid! if options[:force_run]
|
15
|
+
@pid = run_rack_command!
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def stop
|
20
|
+
# Rely on kill_unmanaged_pid if there's no pid
|
21
|
+
return true unless @pid
|
22
|
+
|
23
|
+
exitstatus = kill(@pid)
|
24
|
+
@pid = nil
|
25
|
+
if exitstatus && exitstatus != 0
|
26
|
+
UI.info "Ruby exited with non-zero exit status (#{exitstatus}) whilst trying to stop."
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def restart
|
34
|
+
stop && start
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def build_rack_command
|
40
|
+
command = %w{ruby}
|
41
|
+
command.push(
|
42
|
+
options[:app_file],
|
43
|
+
'--environment', options[:environment].to_s,
|
44
|
+
'--port', options[:port].to_s
|
45
|
+
)
|
46
|
+
command << '--daemonize' if options[:daemon]
|
47
|
+
|
48
|
+
command
|
49
|
+
end
|
50
|
+
|
51
|
+
def kill(pid, force = false)
|
52
|
+
result = -1
|
53
|
+
|
54
|
+
UI.debug("Trying to kill app (PID #{pid})...")
|
55
|
+
unless force
|
56
|
+
Process.kill('INT', pid)
|
57
|
+
begin
|
58
|
+
Timeout.timeout(options[:timeout]) do
|
59
|
+
_, status = Process.wait2(pid)
|
60
|
+
result = status.exitstatus
|
61
|
+
UI.debug("Killed App (Exit status: #{result})")
|
62
|
+
end
|
63
|
+
rescue Timeout::Error
|
64
|
+
UI.debug("Couldn't kill App with INT, switching to TERM")
|
65
|
+
force = true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Process.kill('TERM', pid) if force
|
70
|
+
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
def run_rack_command!
|
75
|
+
command = build_rack_command
|
76
|
+
UI.debug("Running App with command: #{command.inspect}")
|
77
|
+
spawn(*command)
|
78
|
+
end
|
79
|
+
|
80
|
+
def spawn(* args)
|
81
|
+
Spoon.spawnp(* args)
|
82
|
+
end
|
83
|
+
|
84
|
+
def kill_unmanaged_pid!
|
85
|
+
pid = unmanaged_pid
|
86
|
+
kill(pid, true) if pid
|
87
|
+
end
|
88
|
+
|
89
|
+
def unmanaged_pid
|
90
|
+
%x{lsof -n -i TCP:#{options[:port]}}.each_line do |line|
|
91
|
+
return line.split("\s")[1].to_i if line["*:#{options[:port]} "]
|
92
|
+
end
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-goliath
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Norkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: guard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ffi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: spoon
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rb-inotify
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: libnotify
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rack
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Automatically reloads your Goliath app on file change using Guard.
|
126
|
+
email:
|
127
|
+
- zduderman@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rubocop.yml"
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE.md
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- guard-goliath.gemspec
|
139
|
+
- lib/guard-goliath.rb
|
140
|
+
- lib/guard/goliath.rb
|
141
|
+
- lib/guard/goliath/runner.rb
|
142
|
+
- lib/guard/goliath/templates/Guardfile
|
143
|
+
- lib/guard/goliath/version.rb
|
144
|
+
homepage: https://github.com/duderman/guard-goliath
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 2.2.2
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: Automatically reloads your Goliath app on file change using Guard.
|
168
|
+
test_files: []
|
169
|
+
has_rdoc:
|