zoukankan      html  css  js  c++  java
  • python Fabric批量停应用

    import sys,time
    from fabric.api import *
    #env.hosts = ['root@10.10.10.79']
    #env.passwords = {
    #    'root@10.10.10.79':'password'
    #}
    #
    #env.user = 'root'
    
    env.roledefs = {
        "site" : ['o2muser@10.10.10.79','o2muser@10.10.10.79','o2muser@10.10.10.79'],
        "history" : ['wduser@10.10.10.79','wduser@10.10.10.79','wduser@10.10.10.79','wduser@10.10.10.79'],
        "pricing" : ['work@10.10.10.79','work@10.10.10.79','work@10.10.10.79'],
        "masterdata" : ['work@10.10.10.79','work@10.10.10.79'],
        "backup": ['wduser@10.10.10.79']
    
    }
    
    
    
    @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"
  • 相关阅读:
    Codeforces Round #613 选讲
    Codeforces Round #612 选讲
    Codeforces917E
    一道题20
    LOJ#2244. 「NOI2014」起床困难综合症
    求欧拉回路
    *LOJ#2134. 「NOI2015」小园丁与老司机
    vim操作命令
    常见问题解决
    CentOS7下如何修改mysql的数据目录
  • 原文地址:https://www.cnblogs.com/zhangzihong/p/10314520.html
Copyright © 2011-2022 走看看