-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht_kill_tomcat.rb
executable file
·48 lines (36 loc) · 1.07 KB
/
t_kill_tomcat.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/ruby
=begin
--------------------------------------------------------------------------------
Stop Tomcat, if it's running, with a kill command.
Wait for up to 5 more seconds to let it stop. If it doesn't, then complain.
Presumably, you would do this after t_stop_tomcat.rb failed.
--------------------------------------------------------------------------------
=end
$: << File.dirname(File.expand_path(__FILE__))
require 'common'
#
# ---------------------------------------------------------
# MAIN ROUTINE
# ---------------------------------------------------------
#
begin
$instance.tomcat.confirm
raise UserInputError.new("Tomcat is not running.") unless $instance.tomcat.running?
system("kill -9 #{$instance.tomcat.pid}")
puts "Sent kill -9 #{$instance.tomcat.pid}"
4.times do |i|
break unless $instance.tomcat.running?
puts i+1
sleep(1)
end
raise SettingsError.new("Tomcat has not shut down") if $instance.tomcat.running?
puts("Shut down.")
rescue SettingsError
puts
puts $!
puts
rescue UserInputError
puts
puts $!
puts
end