#!/usr/bin/env python
# encoding: utf-8
# 17.51/52:
#
import os
import threading
import sys
def execCmd(cmd):
try:
os.system(cmd)
except Exception, e:
print '%s\t 运行失败,失败原因\r\n%s' % (cmd,e)
if __name__ == '__main__':
start_cmds = [
# ' su - tomcat -c "/data/program/payment/payment-ac/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-account/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-agent/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-ams/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-business/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-channel/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-channel-ota/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-channel-realnameAuth/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-cm/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-cms/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-fastdfs/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-mas/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-order/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-pe/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-pss/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-rcs/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-route/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-security/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-settle/bin/start.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-tasks/bin/start.sh" ',
]
stop_cmds = [
# ' su - tomcat -c "/data/program/payment/payment-ac/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-account/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-agent/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-ams/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-business/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-channel/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-channel-ota/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-channel-realnameAuth/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-cm/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-cms/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-fastdfs/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-mas/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-order/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-pe/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-pss/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-rcs/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-route/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-security/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-settle/bin/stop.sh" ',
# ' su - tomcat -c "/data/program/payment/payment-tasks/bin/stop.sh" ',
]
status_cmds = [
# ' ps -ef | grep "/data/program/payment/payment-ac" ',
# ' ps -ef | grep "/data/program/payment/payment-account" ',
# ' ps -ef | grep "/data/program/payment/payment-agent" ',
# ' ps -ef | grep "/data/program/payment/payment-ams" ',
# ' ps -ef | grep "/data/program/payment/payment-business" ',
# ' ps -ef | grep "/data/program/payment/payment-channel" ',
# ' ps -ef | grep "/data/program/payment/payment-channel-ota" ',
# ' ps -ef | grep "/data/program/payment/payment-channel-realnameAuth" ',
# ' ps -ef | grep "/data/program/payment/payment-cm" ',
# ' ps -ef | grep "/data/program/payment/payment-cms" ',
# ' ps -ef | grep "/data/program/payment/payment-fastdfs" ',
# ' ps -ef | grep "/data/program/payment/payment-mas/bin" ',
# ' ps -ef | grep "/data/program/payment/payment-order" ',
# ' ps -ef | grep "/data/program/payment/payment-pe/bin" ',
# ' ps -ef | grep "/data/program/payment/payment-pss" ',
# ' ps -ef | grep "/data/program/payment/payment-rcs" ',
# ' ps -ef | grep "/data/program/payment/payment-route" ',
# ' ps -ef | grep "/data/program/payment/payment-security" ',
# ' ps -ef | grep "/data/program/payment/payment-settle" ',
# ' ps -ef | grep "/data/program/payment/payment-tasks" ',
]
if sys.argv[1] == 'start':
threads = []
for cmd in start_cmds:
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
threads.append(th)
for th in threads:
th.join()
elif sys.argv[1] == 'stop':
threads = []
for cmd in stop_cmds:
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
threads.append(th)
for th in threads:
th.join()
elif sys.argv[1] == 'status':
threads = []
for cmd in status_cmds:
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
threads.append(th)
for th in threads:
th.join()
elif sys.argv == '-h':
print 'python 17_improper_update.py start|stop|status'
else:
print 'python 17_improper_update.py start|stop|status'