-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht_start_tomcat.rb
executable file
·46 lines (36 loc) · 1.25 KB
/
t_start_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
#! /usr/bin/ruby
=begin
--------------------------------------------------------------------------------
Start Tomcat, if:
it isn't running
it wouldn't collide with another Tomcat
the most recent deploy was successful.
--------------------------------------------------------------------------------
=end
$: << File.dirname(File.expand_path(__FILE__))
require 'common'
#
# ---------------------------------------------------------
# MAIN ROUTINE
# ---------------------------------------------------------
#
begin
$instance.tomcat.confirm
raise UserInputError.new("Tomcat is already running.") if $instance.tomcat.running?
port = $instance.tomcat.port
raise UserInputError.new("Port #{port} is already in use") if RunningTomcats.new().in_use?(port)
props = PropertyFileReader.read("#{$instance.file('_generated/successful')}")
raise UserInputError.new("Previous build failed.") unless props.deploy_success
raise UserInputError.new("The triple store is not available.") unless $instance.knowledge_base.running?
puts `#{$instance.tomcat.path}/bin/catalina.sh start`
code = $?.exitstatus || 0
puts "Exited with code #{code}" unless code == 0
rescue SettingsError
puts
puts $!
puts
rescue UserInputError
puts
puts $!
puts
end