Ejemplo n.º 1
0
 def __remove_work(self):
     log_util.debug("start to remove work dir")
     result = util.run_cmd("rm -rf %swork/Catalina" % self.tomcat_path)
     if result["code"] > 0:
         log_util.error(result["info"][1])
         return False
     return True
Ejemplo n.º 2
0
    def start_deploy(self, wars_with_md5, confs_with_md5):
        if IptableWrap.is_iptables_tom2():
            if self.__run1():
                log_util.info("tom1 is already running start to kill")
                self.tomcat1.force_kill_pre()
            if not self.__run1():
                code, info = self.tomcat1.deploy_new(wars_with_md5,
                                                     confs_with_md5)
                if code > 0:
                    self.tomcat1.force_kill_current()
            else:
                code, info = (111, "kill tom1 fail")
        else:
            if self.__run2():
                log_util.info("tom2 is already running start to kill")
                self.tomcat2.force_kill_pre()
            if not self.__run2():
                code, info = self.tomcat2.deploy_new(wars_with_md5,
                                                     confs_with_md5)
                if code > 0:
                    self.tomcat2.force_kill_current()
            else:
                code, info = (111, "kill tom2 fail")

        if code > 0:
            log_util.error("Deploy error: %s" % info)
            return False, info
        return True, "success"
Ejemplo n.º 3
0
 def __copy_conf(self, conf_with_md5):
     for conf_path in conf_with_md5.keys():
         log_util.debug("start to copy conf src [%s] to dst [%s]" %
                        (conf_path, self.conf_path))
         result = util.copy_not_del(conf_path, self.conf_path)
         if result["code"] > 0:
             log_util.error(result["info"][1])
             return False
     return True
Ejemplo n.º 4
0
 def __copy_war(self, wars_with_md5):
     for war_path in wars_with_md5.keys():
         log_util.debug("start to copy war src [%s] to dst [%s]" %
                        (war_path, self.__tomcat_war_dir_path))
         result = util.copy(war_path, self.__tomcat_war_dir_path)
         if result["code"] > 0:
             log_util.error(result["info"][1])
             return False
     return True
Ejemplo n.º 5
0
 def __remove_unpack(self, wars_with_md5):
     for war_path in wars_with_md5.keys():
         war_name = util.get_file_name(war_path)
         war_pre_name = war_name[:-4]
         log_util.debug("start to remove war: %s", war_name)
         result = util.run_cmd("rm -rf %swebapps/%s" %
                               (self.tomcat_path, war_name))
         if result["code"] > 0:
             log_util.error(result["info"][1])
             return False
         log_util.debug("start to remove war dir: %s", war_pre_name)
         result = util.run_cmd("rm -rf %swebapps/%s" %
                               (self.tomcat_path, war_pre_name))
         if result["code"] > 0:
             log_util.error(result["info"][1])
             return False
     return True
Ejemplo n.º 6
0
def multi(cmd="start",
          wars_with_md5=util.get_wars_with_md5(conf.SRC_WAR_PATH),
          confs_with_md5=util.get_confs_with_md5(conf.SRC_CONF_PATH)):

    init()
    start = time.time()

    deploy_tom = TomcatDeploy(conf.TOMCAT1__PATH, conf.TOMCAT1__CONF_PATH, conf.TOMCAT1__HOST, conf.TOMCAT1__HEART_URL)
    deploy_tom2 = TomcatDeploy(conf.TOMCAT2__PATH, conf.TOMCAT2__CONF_PATH, conf.TOMCAT2__HOST, conf.TOMCAT2_HEART__URL)
    iptable_wrap = IptableWrap(deploy_tom, deploy_tom2)
    if cmd == "start":
        is_success, info = iptable_wrap.start_deploy(wars_with_md5, confs_with_md5)
    elif cmd == "chg":
        is_success, info = iptable_wrap.chg_iptable(wars_with_md5, confs_with_md5)
    else:
        is_success, info = (False, "Unknown cmd for: %s" % cmd)

    if not is_success:
        log_util.error(info)
    log_util.info("%s => total cost: %s" % (cmd, (time.time() - start)))
    return is_success, info
Ejemplo n.º 7
0
 def __start_tomcat(self):
     result = util.run_cmd("/bin/sh %sbin/startup.sh" % self.tomcat_path)
     if result["code"] > 0:
         log_util.error("%s, %s" % (result["info"][0], result["info"][1]))
         return False
     return True
Ejemplo n.º 8
0
def force_kill(pid):
    try:
        os.kill(pid, 9)
        log_util.info('已杀死pid为%s的进程' % pid)
    except OSError, e:
        log_util.error("%s %s 没有如此进程!!!" % (OSError, e))
Ejemplo n.º 9
0
 def has_user_connect(self):
     try:
         self.__request_url()
     except Exception, e:
         log_util.error("%s : %s" % (Exception, e))
         return True