-
Notifications
You must be signed in to change notification settings - Fork 2
/
amf_svc_seas.py
96 lines (91 loc) · 3.84 KB
/
amf_svc_seas.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'''
##################################################################################
# License: MIT
# Copyright 2018 Agile Data Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the # rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE.
##################################################################################
'''
from amf import amfservice
import time
class seas(amfservice):
"""
IBM SEAS
This service controls SEAS.
"""
def __init__(self, svc, home):
amfservice.__init__(self, svc, home)
self.svc = svc
self.home = home
def start(self):
"""start SEAS"""
status = self.run("ps -ef | grep -v grep | grep -v perimeter | grep java| grep seas", printflag=False)
if status == 0:
self.printer.info("seas is already running")
else:
self.printer.info("service starting")
status = self.run(self.home+"/bin/startSeas.sh >/dev/null 2>&1", noWait=True)
if status:
self.printer.error("service start failed")
else:
while True:
time.sleep(3)
status = self.run("ps -ef | grep -v grep | grep -v perimeter | grep java| grep seas", printflag=False)
val = self.outbuf[0]
if val > 0:
break
return status
def stop(self):
"""stop SEAS"""
status = 0
self.printer.info("service stopping")
if self.run(self.home+"/bin/stopSeas.sh mode=auto"):
self.printer.info("killing service")
self.run("kill -9 `ps -ef|grep -v grep| grep -v perimeter | grep seas|grep java|awk '{ print $2 }'` >/dev/null 2>&1; echo")
return status
def restart(self):
"""stops and starts SEAS"""
status = self.stop()
time.sleep(60)
if status == 0:
status = self.start()
return status
def status(self):
"""reports status SEAS"""
self.printer.info("checking service status")
status = 0
found = False
clist = []
clist.append("%-20s%-12s%-10s" % ('PID FILE', 'PID', 'RUNNING'))
clist.append('------------------------------------------')
self.run("ps -ef | grep admin | grep -v grep | grep -v perimeter | grep seas| grep java | cut -c1-30", printflag=True)
line = self.outbuf
pid = 'unknown'
for line in self.outbuf:
vals = line.split()
if len(vals) > 1:
if vals[0] == 'admin':
found = True
pid = vals[1]
break
clist.append("%-20s%-12s%-10s" % ('NA', pid, found))
self.printer.info(clist)
if found:
self.printer.info("seas is running")
else:
self.printer.info("seas is not running")
status = 1
return status