Skip to content

Commit

Permalink
fix log & tars-tools.cmake, support upload by token
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Mar 14, 2020
1 parent 9f12487 commit 9143c7a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
4 changes: 3 additions & 1 deletion servant/libservant/AdminServant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -50,7 +52,7 @@ void AdminServant::shutdown(TarsCurrentPtr current)
::TerminateProcess(hProcess, 0);
#else
kill(getpid(), SIGINT); //通过给自己发信号的方式结束, 避免处理线程结束时自己join自己
// Application::terminate();
// Application::terminate();
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions servant/libservant/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions servant/libservant/AuthLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
25 changes: 19 additions & 6 deletions servant/libservant/ServantHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -361,6 +366,8 @@ void ServantHandle::initialize()

TarsRemoteNotify::getInstance()->report("initialize error: no servant exists.");

TC_Common::msleep(100);

exit(-1);
}

Expand All @@ -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");

TC_Common::msleep(100);

exit(-1);
exit(-1);
}
++it;
}
Expand All @@ -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()));
Expand Down
7 changes: 5 additions & 2 deletions servant/makefile/tars-tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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("-------------------------------------------------------------------------------------")

0 comments on commit 9143c7a

Please sign in to comment.