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(graphics)
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_quazip()
target_openssl()
add_crashpad()
target_breakpad()
# libcrypto uses dlopen in libdl
if (UNIX)
target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS})

View file

@ -85,6 +85,8 @@ QUuid DomainServer::_overridingDomainID;
bool DomainServer::_getTempName { false };
QString DomainServer::_userConfigFilename;
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.
/// @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");
parser.addOption(logOption);
const QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize.");
parser.addOption(forceCrashReportingOption);
QStringList arguments;
for (int i = 0; i < argc; ++i) {
@ -488,6 +492,10 @@ void DomainServer::parseCommandLine(int argc, char* argv[]) {
qDebug() << "Parent process PID is" << _parentPID;
}
}
if (parser.isSet(forceCrashReportingOption)) {
_forceCrashReporting = true;
}
}
DomainServer::~DomainServer() {

View file

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

View file

@ -21,6 +21,8 @@
#include <SharedUtil.h>
#include "DomainServer.h"
#include <crash-handler/CrashHandler.h>
int main(int argc, char* argv[]) {
setupHifiApplication(BuildInfo::DOMAIN_SERVER_NAME);
@ -32,9 +34,21 @@ int main(int argc, char* argv[]) {
int currentExitCode = 0;
// 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 {
crash::annotations::setShutdownState(false);
DomainServer domainServer(argc, argv);
ch.startMonitor(&domainServer);
currentExitCode = domainServer.exec();
} 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";
}
ch.setAnnotation("program", "interface");
const QString& applicationName = getInterfaceSharedMemoryName();
bool instanceMightBeRunning = true;
#ifdef Q_OS_WIN