fix log & tars-tools.cmake, support upload by token

This commit is contained in:
ruanshudong 2020-03-14 17:53:34 +08:00
parent 9f124879e7
commit 9143c7a61a
5 changed files with 32 additions and 11 deletions

View File

@ -40,6 +40,8 @@ void AdminServant::destroy()
void AdminServant::shutdown(TarsCurrentPtr current)
{
TLOGERROR("[TARS][AdminServant::shutdown]" << endl);
#if TARGET_PLATFORM_WINDOWS
HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
if (hProcess == NULL)
@ -50,7 +52,7 @@ void AdminServant::shutdown(TarsCurrentPtr current)
::TerminateProcess(hProcess, 0);
#else
kill(getpid(), SIGINT); //通过给自己发信号的方式结束, 避免处理线程结束时自己join自己
// Application::terminate();
// Application::terminate();
#endif
}

View File

@ -47,11 +47,14 @@ namespace tars
#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS
static void sighandler( int sig_no )
{
TLOGERROR("[TARS][sighandler] sig_no :" << sig_no << endl);
Application::terminate();
}
#else
static BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
{
TLOGERROR("[TARS][sighandler] sig_no :" << sig_no << endl);
Application::terminate();
ExitProcess(0);
return TRUE;

View File

@ -39,7 +39,7 @@ bool processAuth(TC_EpollServer::Connection *conn, const shared_ptr<TC_EpollServ
int type = adapter->getEndpoint().getAuthType();
if (type == AUTH_TYPENONE)
{
adapter->getEpollServer()->info("[TARS]processAuth no need auth func, auth succ");
adapter->getEpollServer()->info("processAuth no need auth func, auth succ");
conn->_authState = AUTH_SUCC;
return false;
}
@ -59,7 +59,7 @@ bool processAuth(TC_EpollServer::Connection *conn, const shared_ptr<TC_EpollServ
}
catch(...)
{
adapter->getEpollServer()->error("[TARS]processAuth tars protocol decode error, close connection.");
adapter->getEpollServer()->error("processAuth tars protocol decode error, close connection.");
conn->setClose();
return true;

View File

@ -348,8 +348,13 @@ void ServantHandle::initialize()
}
else
{
TLOGERROR("[TAF]ServantHandle initialize createServant ret null, for adapter `" +_bindAdapter->getName() + "`" << endl);
cerr << "[TAF]ServantHandle initialize createServant ret null, for adapter `" +_bindAdapter->getName() + "`" << endl;
TLOGERROR("[TARS]ServantHandle initialize createServant ret null, for adapter `" +_bindAdapter->getName() + "`" << endl);
cerr << "[TARS]ServantHandle initialize createServant ret null, for adapter `" +_bindAdapter->getName() + "`" << endl;
TarsRemoteNotify::getInstance()->report("initialize createServant error: no adapter:" + _bindAdapter->getName());
TC_Common::msleep(100);
exit(-1);
}
@ -361,6 +366,8 @@ void ServantHandle::initialize()
TarsRemoteNotify::getInstance()->report("initialize error: no servant exists.");
TC_Common::msleep(100);
exit(-1);
}
@ -380,15 +387,19 @@ void ServantHandle::initialize()
TarsRemoteNotify::getInstance()->report("initialize error:" + string(ex.what()));
exit(-1);
TC_Common::msleep(100);
exit(-1);
}
catch(...)
{
TLOGERROR("[TARS]initialize unknown exception error" << endl);
TarsRemoteNotify::getInstance()->report("initialize error");
TarsRemoteNotify::getInstance()->report("initialize unknown exception error");
exit(-1);
TC_Common::msleep(100);
exit(-1);
}
++it;
}
@ -404,7 +415,9 @@ void ServantHandle::heartbeat()
TARS_KEEPALIVE(_bindAdapter->getName());
//上报连接数 比率
// TLOGERROR("[TARS]ServantHandle::handle heartbeat:" << _bindAdapter->getName() << endl);
//上报连接数 比率
if (_bindAdapter->_pReportConRate)
{
_bindAdapter->_pReportConRate->report((int)(_bindAdapter->getNowConnection() * 1000 / _bindAdapter->getMaxConns()));

View File

@ -56,6 +56,8 @@ IF (TARS_WEB_HOST STREQUAL "")
set(TARS_WEB_HOST "http://web.tars.com")
ENDIF ()
set(TARS_TOKEN "" CACHE STRING "set web token")
set(PLATFORM)
IF (UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
@ -180,8 +182,8 @@ macro(gen_server APP TARGET)
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${TARS_PATH}\\cpp\\\\script\\\\WinSCP.exe sftp://${TARS_WEB_SERVER}/usr/local/app/patchs/tars.upload/ /upload ${APP}.${TARGET}.tgz)\n")
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${TARS_PATH}\\cpp\\\\script\\\\busybox.exe wget -O ${APP}.${TARGET}.wget.out http://${TARS_WEB_HOST}/doUpload.jsp?SERVER=${APP}.${TARGET}&TGZ=/usr/local/app/patchs/tars.upload/${APP}.${TARGET}.tgz)\n")
ELSE()
FILE(WRITE ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo ${TARS_WEB_HOST}/pages/server/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=dev)\n")
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND curl ${TARS_WEB_HOST}/pages/server/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=dev)\n")
FILE(WRITE ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo ${TARS_WEB_HOST}/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n")
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND curl ${TARS_WEB_HOST}/api/upload_and_publish?ticket=${TARS_TOKEN} -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n")
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo \n---------------------------------------------------------------------------)\n")
ENDIF()
@ -254,5 +256,6 @@ message("TARS_MYSQL: ${TARS_MYSQL}")
message("TARS_HTTP2: ${TARS_HTTP2}")
message("TARS_SSL: ${TARS_SSL}")
message("TARS_WEB_HOST: ${TARS_WEB_HOST}")
message("TARS_TOKEN: ${TARS_TOKEN}")
message("-------------------------------------------------------------------------------------")