diff --git a/src/cm_agent/cma_instance_management_res.cpp b/src/cm_agent/cma_instance_management_res.cpp index 3a01f8086203a218468afadb6843dfa81d598e7b..83b406696e8f7c5c595670a5ebbe1615fe9850e6 100644 --- a/src/cm_agent/cma_instance_management_res.cpp +++ b/src/cm_agent/cma_instance_management_res.cpp @@ -118,13 +118,13 @@ void OneResInstClean(const CmResConfList *oneResConf) } } -status_t RegOneResInst(const CmResConfList *conf, uint32 destInstId) +status_t RegOneResInst(const CmResConfList *conf, uint32 destInstId, bool8 needNohup) { char oper[MAX_OPTION_LEN] = {0}; int ret = snprintf_s(oper, MAX_OPTION_LEN, MAX_OPTION_LEN - 1, "-reg %u %s", destInstId, conf->arg); securec_check_intval(ret, (void)ret); - ret = CusResCmdExecute(conf->script, oper, (uint32)conf->checkInfo.timeOut, CM_TRUE); + ret = CusResCmdExecute(conf->script, oper, (uint32)conf->checkInfo.timeOut, needNohup); if (ret != 0) { write_runlog(ERROR, "[%s]: cmd:(%s %s) execute failed, ret=%d.\n", __FUNCTION__, conf->script, oper, ret); return CM_ERROR; @@ -301,8 +301,12 @@ static bool CanCusInstDoRestart(const CmResConfList *conf) if ((stat == CM_RES_ISREG_REG) || (stat == CM_RES_ISREG_NOT_SUPPORT)) { return true; } - write_runlog(LOG, "cur inst(%u) isreg stat=(%u), can't do restart.\n", conf->cmInstanceId, (uint32)stat); - return false; + if (RegOneResInst(conf, conf->resInstanceId, CM_FALSE) != CM_SUCCESS) { + write_runlog(LOG, "cur inst(%u) isreg stat=(%u), and reg failed, can't do restart.\n", conf->cmInstanceId, + (uint32)stat); + return false; + } + return true; } static inline status_t RestartOneResInst(CmResConfList *conf) diff --git a/src/cm_agent/cma_process_messages_client.cpp b/src/cm_agent/cma_process_messages_client.cpp index 02fb902a14c729765643949b4a8dc736bf29e584..a9faabb27ab3c04e0aaf6f329bc1a83572640161 100644 --- a/src/cm_agent/cma_process_messages_client.cpp +++ b/src/cm_agent/cma_process_messages_client.cpp @@ -351,7 +351,7 @@ static void ProcessRegResInst(const CmsNotifyAgentRegMsg *recvMsg) } else if ((isreg == CM_RES_ISREG_UNREG) || (isreg == CM_RES_ISREG_PENDING) || (isreg == CM_RES_ISREG_UNKNOWN)) { write_runlog(LOG, "before reg res inst, need clean res inst first.\n"); if ((CheckOneResInst(local) == CUS_RES_CHECK_STAT_OFFLINE) || (CleanOneResInst(local) == CM_SUCCESS)) { - (void)RegOneResInst(local, recvMsg->resInstId); + (void)RegOneResInst(local, recvMsg->resInstId, CM_TRUE); } } else if (isreg == CM_RES_ISREG_NOT_SUPPORT) { write_runlog(LOG, "res inst[%s:%u] don't support reg, not need reg.\n", recvMsg->resName, recvMsg->resInstId); diff --git a/src/include/cm/cm_agent/cma_instance_management_res.h b/src/include/cm/cm_agent/cma_instance_management_res.h index 1df7cc4b5e87ea8c181ed7fc24c09b6780b41ebc..ae4bc9c81cf05273fc1c24d52b31227469b2b606 100644 --- a/src/include/cm/cm_agent/cma_instance_management_res.h +++ b/src/include/cm/cm_agent/cma_instance_management_res.h @@ -30,7 +30,7 @@ status_t StartOneResInst(const CmResConfList *conf); void StopOneResInst(const CmResConfList *conf); void OneResInstShutdown(const CmResConfList *oneResConf); -status_t RegOneResInst(const CmResConfList *conf, uint32 destInstId); +status_t RegOneResInst(const CmResConfList *conf, uint32 destInstId, bool8 needNohup); status_t UnregOneResInst(const CmResConfList *conf, uint32 destInstId); ResIsregStatus IsregOneResInst(const CmResConfList *conf, uint32 destInstId); status_t CleanOneResInst(const CmResConfList *conf);