|
@@ -722,8 +722,8 @@ void CHealthManagerEntity::OnCheckTimeTimeout()
|
|
|
m_bSayIdle = true;
|
|
|
if (bCheckGuardian)
|
|
|
{
|
|
|
- eErr = m_pfUpgradeRestart(3, 0);
|
|
|
- Dbg("healthmanager say idle,so tell the guardian.%d",eErr);
|
|
|
+ int ret = m_pfUpgradeRestart(3, 0);
|
|
|
+ Dbg("healthmanager say idle,so tell the guardian.%d",ret);
|
|
|
}
|
|
|
CSimpleStringA csRunInfo,csStartTime;
|
|
|
if ((GetFunction()->GetPath("RunInfo",csRunInfo)) != Error_Succeed)
|
|
@@ -745,9 +745,9 @@ void CHealthManagerEntity::OnCheckTimeTimeout()
|
|
|
{
|
|
|
WorkStateEnum eShake;
|
|
|
Dbg("to shake...");
|
|
|
- ErrorCodeEnum eErrShake = m_pfShake(eShake);
|
|
|
+ int ret = m_pfShake(eShake);
|
|
|
//if (eErrShake != Error_Succeed)
|
|
|
- Dbg("shake hand result:%d,work state %d",eErrShake,eShake);
|
|
|
+ Dbg("shake hand result:%d,work state %d",ret,eShake);
|
|
|
if (!m_bHealthInit)
|
|
|
{
|
|
|
bool bStop = StopGuardian();
|
|
@@ -773,8 +773,8 @@ void CHealthManagerEntity::OnCheckTimeTimeout()
|
|
|
{
|
|
|
if (CheckGuardianIsRun(true))
|
|
|
{
|
|
|
- eErr = m_pfUpgradeRestart(5, 0);
|
|
|
- Dbg("auth suc,so tell the guardian.%d", eErr);
|
|
|
+ int ret = m_pfUpgradeRestart(5, 0);
|
|
|
+ Dbg("auth suc,so tell the guardian.%d", ret);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1018,6 +1018,45 @@ bool CHealthManagerEntity::StartGuardian()
|
|
|
DWORD dwErr = GetLastError();
|
|
|
return true;
|
|
|
#else
|
|
|
+ /*
|
|
|
+ char app[MAX_PATH];
|
|
|
+ memset(app, 0, sizeof(app));
|
|
|
+ tk_process_t* process = NULL;
|
|
|
+ tk_process_option_t option;
|
|
|
+ sprintf(app, "./bin/guardian");
|
|
|
+ option.exit_cb = NULL;
|
|
|
+ option.file = NULL;
|
|
|
+ option.flags = 0;
|
|
|
+ option.params = app;
|
|
|
+
|
|
|
+ if (0 == process_spawn(&option, &process)) {
|
|
|
+ //new_process->pid = process->pid;
|
|
|
+ //new_process->handle = process->handle;
|
|
|
+ FREE(process);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ char app[MAX_PATH];
|
|
|
+ memset(app,0, sizeof(app));
|
|
|
+ tk_process_t* process = NULL;
|
|
|
+ tk_process_option_t option;
|
|
|
+ csBinPath += "/guardian";
|
|
|
+ Dbg("path:%s",(const char*)csBinPath);
|
|
|
+ sprintf(app, "%s %s %d", csBinPath,"oiltest",1);
|
|
|
+ option.exit_cb = NULL;
|
|
|
+ option.file = NULL;
|
|
|
+ option.flags = 0;
|
|
|
+ option.params = app;
|
|
|
+
|
|
|
+ if (0 == process_spawn(&option, &process)) {
|
|
|
+ Dbg("process_spawn guardian");
|
|
|
+ FREE(process);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Dbg("end of StartGuardian");
|
|
|
+ */
|
|
|
+
|
|
|
+ Dbg("to vfork.");
|
|
|
int i;
|
|
|
pid_t pid = vfork();
|
|
|
if (pid == 0)
|
|
@@ -1027,29 +1066,41 @@ bool CHealthManagerEntity::StartGuardian()
|
|
|
//×Ó½ø³Ìµ÷ÓÃexecle
|
|
|
csBinPath += "/guardian";
|
|
|
Dbg("guardian.exe(linux) path:%s", (const char*)csBinPath);
|
|
|
- char* newargv[] = { "oil","test",NULL };
|
|
|
- char* newenv[] = { NULL };
|
|
|
- newargv[0] = (char*)csBinPath.GetData();
|
|
|
- if (execve((const char*)csBinPath, newargv, newenv) < 0)
|
|
|
+ bool bExeFileExist = (access((const char*)csBinPath, F_OK) == 0);
|
|
|
+ if (bExeFileExist)
|
|
|
{
|
|
|
- Dbg("execle failed_error ID:%d,%s", errno, strerror(errno));
|
|
|
- //_exit(0);
|
|
|
- return false;
|
|
|
+ char* newargv[] = { "oil","test",NULL };
|
|
|
+ char* newenv[] = { NULL };
|
|
|
+ newargv[0] = (char*)csBinPath.GetData();
|
|
|
+ if (execve((const char*)csBinPath, newargv, newenv) < 0)
|
|
|
+ {
|
|
|
+ Dbg("execle failed_error ID:%d,%s", errno, strerror(errno));
|
|
|
+ _exit(0);
|
|
|
+ //return false;
|
|
|
+ }
|
|
|
+ Dbg("can't reach here");
|
|
|
+ _exit(0);
|
|
|
+ //return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Dbg("guardian file not exsit.");
|
|
|
+ _exit(0);
|
|
|
+ //return false;
|
|
|
}
|
|
|
- Dbg("can't reach here");
|
|
|
}
|
|
|
else if (pid < 0)
|
|
|
{
|
|
|
Dbg("vfork failed.");
|
|
|
+ return false;
|
|
|
//exit(1);
|
|
|
//int wait_rv; //return value from wait()
|
|
|
//wait_rv = wait(NULL);
|
|
|
//Dbg("done waiting for child %d. Wait returned:%d\n", pid, wait_rv);
|
|
|
//_exit(0);
|
|
|
}
|
|
|
- else
|
|
|
- Dbg("end of StartGuardian");
|
|
|
-
|
|
|
+ Dbg("end of StartGuardian");
|
|
|
+ return true;
|
|
|
|
|
|
#endif //RVC_OS_WIN
|
|
|
}
|
|
@@ -1141,12 +1192,12 @@ bool CHealthManagerEntity::DoRestart()
|
|
|
}
|
|
|
|
|
|
#ifdef linux
|
|
|
- deamonBasePath += "/GuardianBase.so";
|
|
|
+ deamonBasePath += "/libGuardianBase.so";
|
|
|
Dbg("gd path [%s]", (LPCTSTR)deamonBasePath);
|
|
|
void* handle = dlopen(deamonBasePath, RTLD_LAZY);
|
|
|
if (handle == NULL)
|
|
|
{
|
|
|
- Dbg("load GuardianBase.so failed(%d)", errno);
|
|
|
+ Dbg("load libGuardianBase.so failed(%d)", errno);
|
|
|
return Error_IO;
|
|
|
}
|
|
|
m_pfShake = (pfShakeHands)dlsym(handle, "ShakeHands");
|
|
@@ -1188,8 +1239,8 @@ bool CHealthManagerEntity::DoRestart()
|
|
|
{
|
|
|
Sleep(500);
|
|
|
Dbg("to tell guardian framework is starting.");
|
|
|
- eErr = m_pfUpgradeRestart(4, 0);//tell guardian framework is starting...oilyang 20150514
|
|
|
- Dbg("feedback of framework is starting.%d",eErr);
|
|
|
+ int ret = m_pfUpgradeRestart(4, 0);//tell guardian framework is starting...oilyang 20150514
|
|
|
+ Dbg("feedback of framework is starting.%d",ret);
|
|
|
}
|
|
|
m_currentVer = "";
|
|
|
UpdateSiteToRuncfg();
|
|
@@ -1669,8 +1720,8 @@ void CHealthManagerEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nL
|
|
|
if (CheckGuardianIsRun(true))
|
|
|
{
|
|
|
ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
- eErr = m_pfUpgradeRestart(1, 0);
|
|
|
- Dbg("to tell guardian framework is restarting.%d",eErr);
|
|
|
+ int ret = m_pfUpgradeRestart(1, 0);
|
|
|
+ Dbg("to tell guardian framework is restarting.%d",ret);
|
|
|
}
|
|
|
m_eRebootTrigger = RebootTrigger_FrameUpgrade;
|
|
|
}
|