terminate 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +15 -0
- data/bin/terminate +4 -16
- data/lib/tasks/terminate.rake +9 -0
- data/lib/terminate.rb +2 -0
- data/lib/terminate/options.rb +29 -0
- data/lib/terminate/railtie.rb +9 -0
- data/lib/terminate/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fe02caeda6ad45c1110c7d2786aef2503ba5a06
|
4
|
+
data.tar.gz: ffa08e566c228ce43a89668e2d90256880b41e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df3bc5122cfcc0f2532271dfaa02b986dbe979a8272a1e0c1286312d0523e3b5108e42ceacb2a6fcd7d27bc86cd7f59022cc79b25b8f36d35cee6ee827257a8d
|
7
|
+
data.tar.gz: 189c41a2f443ee4aa9643c99ca2160ca5a693f237a73c89c5e1231b1235ca3e53b0822c3925e06d6a8fba25bcad92a1e006727a0269625b7efd3f952ff290f72
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -32,6 +32,21 @@ Terminate.execute(pid, 30)
|
|
32
32
|
Terminate.execute(pid, 30, 'USR1')
|
33
33
|
```
|
34
34
|
|
35
|
+
### Rake
|
36
|
+
You can alos run by `rake`:
|
37
|
+
|
38
|
+
bundle exec terminate [pid] -- [options]
|
39
|
+
|
40
|
+
Eg.
|
41
|
+
|
42
|
+
# default timeout is 10 seconds
|
43
|
+
bundle exec terminate 1234
|
44
|
+
|
45
|
+
# set timeout 30
|
46
|
+
bundle exec terminate 1234 -- -t 30
|
47
|
+
# or
|
48
|
+
bundle exec terminate 1234 -- --timeout=30
|
49
|
+
|
35
50
|
### Command Line
|
36
51
|
You can alos run by `terminate` in command line.
|
37
52
|
|
data/bin/terminate
CHANGED
@@ -4,27 +4,15 @@ require 'optparse'
|
|
4
4
|
require 'logger'
|
5
5
|
require 'terminate'
|
6
6
|
|
7
|
-
|
8
|
-
options = {}
|
9
|
-
OptionParser.new do |opts|
|
10
|
-
opts.banner = "Usage: wait_stop [pid] [options]"
|
11
|
-
opts.on('-t', '--timeout=TIMEOUT', 'Timeout to kill(seconds, default is 10)') { |v| options[:timeout] = v }
|
12
|
-
opts.on('-s', '--signal=SIGNAL', 'SIGNAL to terminate(default TERM)') { |v| options[:signal] = v }
|
13
|
-
help = opts.to_s
|
14
|
-
end.parse!
|
7
|
+
options = Terminate::Options.new
|
15
8
|
|
16
|
-
pid
|
17
|
-
|
18
|
-
puts help
|
9
|
+
if options.pid <= 0
|
10
|
+
puts options.help
|
19
11
|
exit
|
20
12
|
end
|
21
13
|
|
22
|
-
timeout = options[:timeout].to_i
|
23
|
-
timeout = 10 if timeout <= 0
|
24
|
-
signal = options[:signal] || 'TERM'
|
25
|
-
|
26
14
|
Terminate.logger = Logger.new(STDOUT)
|
27
15
|
Terminate.logger.formatter = proc do |severity, datetime, progname, msg|
|
28
16
|
"#{msg}\n"
|
29
17
|
end
|
30
|
-
Terminate.execute(pid, timeout, signal)
|
18
|
+
Terminate.execute(options.pid, options.timeout, options.signal)
|
data/lib/terminate.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Terminate
|
2
|
+
class Options
|
3
|
+
attr_reader :help
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@help = ''
|
7
|
+
@options = {}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: wait_stop [pid] [options]"
|
10
|
+
opts.on('-t', '--timeout=TIMEOUT', 'Timeout to kill(seconds, default is 10)') { |v| @options[:timeout] = v }
|
11
|
+
opts.on('-s', '--signal=SIGNAL', 'SIGNAL to terminate(default TERM)') { |v| @options[:signal] = v }
|
12
|
+
@help = opts.to_s
|
13
|
+
end.parse!
|
14
|
+
end
|
15
|
+
|
16
|
+
def pid
|
17
|
+
ARGV[0].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
def timeout
|
21
|
+
timeout = @options[:timeout].to_i
|
22
|
+
timeout <= 0 ? 10 : timeout
|
23
|
+
end
|
24
|
+
|
25
|
+
def signal
|
26
|
+
@options[:signal] || 'TERM'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/terminate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chen Yi-Cyuan
|
@@ -111,7 +111,10 @@ files:
|
|
111
111
|
- README.md
|
112
112
|
- Rakefile
|
113
113
|
- bin/terminate
|
114
|
+
- lib/tasks/terminate.rake
|
114
115
|
- lib/terminate.rb
|
116
|
+
- lib/terminate/options.rb
|
117
|
+
- lib/terminate/railtie.rb
|
115
118
|
- lib/terminate/version.rb
|
116
119
|
- terminate.gemspec
|
117
120
|
homepage: https://github.com/emn178/terminate
|
@@ -134,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
137
|
version: '0'
|
135
138
|
requirements: []
|
136
139
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.4.
|
140
|
+
rubygems_version: 2.4.5
|
138
141
|
signing_key:
|
139
142
|
specification_version: 4
|
140
143
|
summary: Terminate process or kill if timeout.
|