Make crash reporting work on domain-server

This commit is contained in:
Dale Glass 2023-06-26 01:02:22 +02:00
parent 4dcc2882fd
commit 2cfac3a896
5 changed files with 32 additions and 1 deletions

View file

@ -30,12 +30,15 @@ symlink_or_copy_directory_beside_target(${_SHOULD_SYMLINK_RESOURCES} "${CMAKE_CU
include_hifi_library_headers(gpu) include_hifi_library_headers(gpu)
include_hifi_library_headers(graphics) include_hifi_library_headers(graphics)
include_hifi_library_headers(script-engine) include_hifi_library_headers(script-engine)
link_hifi_libraries(embedded-webserver networking shared avatars octree) link_hifi_libraries(embedded-webserver networking shared avatars octree monitoring)
target_zlib() target_zlib()
target_quazip() target_quazip()
target_openssl() target_openssl()
add_crashpad()
target_breakpad()
# libcrypto uses dlopen in libdl # libcrypto uses dlopen in libdl
if (UNIX) if (UNIX)
target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS}) target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS})

View file

@ -85,6 +85,8 @@ QUuid DomainServer::_overridingDomainID;
bool DomainServer::_getTempName { false }; bool DomainServer::_getTempName { false };
QString DomainServer::_userConfigFilename; QString DomainServer::_userConfigFilename;
int DomainServer::_parentPID { -1 }; int DomainServer::_parentPID { -1 };
bool DomainServer::_forceCrashReporting{false};
/// @brief The Domain server can proxy requests to the Directory Server, this function handles those forwarding requests. /// @brief The Domain server can proxy requests to the Directory Server, this function handles those forwarding requests.
/// @param connection The HTTP connection object. /// @param connection The HTTP connection object.
@ -417,6 +419,8 @@ void DomainServer::parseCommandLine(int argc, char* argv[]) {
const QCommandLineOption logOption("logOptions", "Logging options, comma separated: color,nocolor,process_id,thread_id,milliseconds,keep_repeats,journald,nojournald", "options"); const QCommandLineOption logOption("logOptions", "Logging options, comma separated: color,nocolor,process_id,thread_id,milliseconds,keep_repeats,journald,nojournald", "options");
parser.addOption(logOption); parser.addOption(logOption);
const QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize.");
parser.addOption(forceCrashReportingOption);
QStringList arguments; QStringList arguments;
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
@ -488,6 +492,10 @@ void DomainServer::parseCommandLine(int argc, char* argv[]) {
qDebug() << "Parent process PID is" << _parentPID; qDebug() << "Parent process PID is" << _parentPID;
} }
} }
if (parser.isSet(forceCrashReportingOption)) {
_forceCrashReporting = true;
}
} }
DomainServer::~DomainServer() { DomainServer::~DomainServer() {

View file

@ -83,6 +83,8 @@ public:
void screensharePresence(QString roomname, QUuid avatarID, int expiration_seconds = 0); void screensharePresence(QString roomname, QUuid avatarID, int expiration_seconds = 0);
static bool forceCrashReporting() { return _forceCrashReporting; }
public slots: public slots:
/// Called by NodeList to inform us a node has been added /// Called by NodeList to inform us a node has been added
void nodeAdded(SharedNodePointer node); void nodeAdded(SharedNodePointer node);
@ -311,6 +313,8 @@ private:
static bool _getTempName; static bool _getTempName;
static QString _userConfigFilename; static QString _userConfigFilename;
static int _parentPID; static int _parentPID;
static bool _forceCrashReporting;
bool _sendICEServerAddressToMetaverseAPIInProgress { false }; bool _sendICEServerAddressToMetaverseAPIInProgress { false };
bool _sendICEServerAddressToMetaverseAPIRedo { false }; bool _sendICEServerAddressToMetaverseAPIRedo { false };

View file

@ -21,6 +21,8 @@
#include <SharedUtil.h> #include <SharedUtil.h>
#include "DomainServer.h" #include "DomainServer.h"
#include <crash-handler/CrashHandler.h>
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
setupHifiApplication(BuildInfo::DOMAIN_SERVER_NAME); setupHifiApplication(BuildInfo::DOMAIN_SERVER_NAME);
@ -32,9 +34,21 @@ int main(int argc, char* argv[]) {
int currentExitCode = 0; int currentExitCode = 0;
// use a do-while to handle domain-server restart // use a do-while to handle domain-server restart
auto &ch = CrashHandler::getInstance();
ch.start(argv[0]);
if ( DomainServer::forceCrashReporting() ) {
ch.setEnabled(true);
}
ch.setAnnotation("program", "domain-server");
do { do {
crash::annotations::setShutdownState(false); crash::annotations::setShutdownState(false);
DomainServer domainServer(argc, argv); DomainServer domainServer(argc, argv);
ch.startMonitor(&domainServer);
currentExitCode = domainServer.exec(); currentExitCode = domainServer.exec();
} while (currentExitCode == DomainServer::EXIT_CODE_REBOOT); } while (currentExitCode == DomainServer::EXIT_CODE_REBOOT);

View file

@ -344,6 +344,8 @@ int main(int argc, const char* argv[]) {
qWarning() << "Crash handler failed to start"; qWarning() << "Crash handler failed to start";
} }
ch.setAnnotation("program", "interface");
const QString& applicationName = getInterfaceSharedMemoryName(); const QString& applicationName = getInterfaceSharedMemoryName();
bool instanceMightBeRunning = true; bool instanceMightBeRunning = true;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN