import sys,time from fabric.api import * #env.hosts = ['[email protected]'] #env.passwords = { # '[email protected]':'password' #} # #env.user = 'root' env.roledefs = { "site" : ['[email protected]','[email protected]','[email protected]'], "history" : ['[email protected]','[email protected]','[email protected]','[email protected]'], "pricing" : ['[email protected]','[email protected]','[email protected]'], "masterdata" : ['[email protected]','[email protected]'], "backup": ['[email protected]'] } @task @roles('site') def site_stop(): msg = run("ps -ef | grep site-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'|xargs kill -9") print msg if msg.failed: print red("fail") print "success" @task @roles('history') def history_stop(): msg = run("ps -ef | grep history-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'|xargs kill -9") print msg if msg.failed: print red("fail") print "success" @task @roles('pricing') def pricing_stop(): msg = run("ps -ef | grep pricing-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'|xargs kill -9") print msg if msg.failed: print red("fail") print "success" @task @roles('masterdata') def masterdata_stop(): msg = run("ps -ef | grep masterdata-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'|xargs kill -9") print msg if msg.failed: print red("fail") print "success" @task @roles(bckup'') def bckup_stop(): msg = run("ps -ef | grep backup-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'|xargs kill -9") print msg if msg.failed: print red("fail") print "success"
python Fabric批量停应用
猜你喜欢
转载自www.cnblogs.com/zhangzihong/p/10314520.html
今日推荐
周排行