delay critical quit messages until just prior to quit

This commit is contained in:
Stephen Birarda 2016-02-11 15:11:21 -08:00
parent 99e9b3ecdd
commit aaf8e60de3
3 changed files with 34 additions and 16 deletions

View file

@ -120,6 +120,14 @@ DomainServer::~DomainServer() {
DependencyManager::destroy<LimitedNodeList>();
}
void DomainServer::queuedQuit(QString quitMessage, int exitCode) {
if (!quitMessage.isEmpty()) {
qCritical() << qPrintable(quitMessage);
}
QCoreApplication::exit(exitCode);
}
void DomainServer::aboutToQuit() {
// clear the log handler so that Qt doesn't call the destructor on LogHandler
@ -164,8 +172,11 @@ bool DomainServer::optionallyReadX509KeyAndCertificate() {
qDebug() << "TCP server listening for HTTPS connections on" << DOMAIN_SERVER_HTTPS_PORT;
} else if (!certPath.isEmpty() || !keyPath.isEmpty()) {
qDebug() << "Missing certificate or private key. domain-server will now quit.";
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
static const QString MISSING_CERT_ERROR_MSG = "Missing certificate or private key. domain-server will now quit.";
static const int MISSING_CERT_ERROR_CODE = 3;
QMetaObject::invokeMethod(this, "queuedQuit", Qt::QueuedConnection,
Q_ARG(QString, MISSING_CERT_ERROR_MSG), Q_ARG(int, MISSING_CERT_ERROR_CODE));
return false;
}
@ -199,8 +210,10 @@ bool DomainServer::optionallySetupOAuth() {
|| _hostname.isEmpty()
|| _oauthClientID.isEmpty()
|| _oauthClientSecret.isEmpty()) {
qDebug() << "Missing OAuth provider URL, hostname, client ID, or client secret. domain-server will now quit.";
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
static const QString MISSING_OAUTH_INFO_MSG = "Missing OAuth provider URL, hostname, client ID, or client secret. domain-server will now quit.";
static const int MISSING_OAUTH_INFO_ERROR_CODE = 1542;
QMetaObject::invokeMethod(this, "queuedQuit", Qt::QueuedConnection,
Q_ARG(QString, MISSING_OAUTH_INFO_MSG), Q_ARG(int, MISSING_OAUTH_INFO_ERROR_CODE));
return false;
} else {
qDebug() << "OAuth will be used to identify clients using provider at" << _oauthProviderURL.toString();
@ -404,9 +417,13 @@ bool DomainServer::resetAccountManagerAccessToken() {
return true;
} else {
qDebug() << "Missing OAuth provider URL, but a domain-server feature was required that requires authentication." <<
"domain-server will now quit.";
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
static const QString MISSING_OAUTH_PROVIDER_MSG =
QString("Missing OAuth provider URL, but a domain-server feature was required that requires authentication.") +
QString("domain-server will now quit.");
static const int MISSING_OAUTH_PROVIDER_ERROR_CODE = 5323;
QMetaObject::invokeMethod(this, "queuedQuit", Qt::QueuedConnection,
Q_ARG(QString, MISSING_OAUTH_PROVIDER_MSG),
Q_ARG(int, MISSING_OAUTH_PROVIDER_ERROR_CODE));
return false;
}
@ -517,11 +534,6 @@ void DomainServer::setupICEHeartbeatForFullNetworking() {
}
}
void DomainServer::loginFailed() {
qDebug() << "Login to data server has failed. domain-server will now quit";
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
}
void DomainServer::parseAssignmentConfigs(QSet<Assignment::Type>& excludedTypes) {
// check for configs from the command line, these take precedence
const QString ASSIGNMENT_CONFIG_REGEX_STRING = "config-([\\d]+)";

View file

@ -65,7 +65,6 @@ public slots:
private slots:
void aboutToQuit();
void loginFailed();
void setupPendingAssignmentCredits();
void sendPendingTransactionsToServer();
@ -77,6 +76,8 @@ private slots:
void handleTempDomainSuccess(QNetworkReply& requestReply);
void handleTempDomainError(QNetworkReply& requestReply);
void queuedQuit(QString quitMessage, int exitCode);
private:
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());

View file

@ -62,9 +62,14 @@ DomainServerSettingsManager::DomainServerSettingsManager() :
}
}
qCritical() << "Did not find settings decription in JSON at" << SETTINGS_DESCRIPTION_RELATIVE_PATH
<< "- Unable to continue. domain-server will quit.";
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
static const QString MISSING_SETTINGS_DESC_MSG =
QString("Did not find settings decription in JSON at %1 - Unable to continue. domain-server will quit.")
.arg(SETTINGS_DESCRIPTION_RELATIVE_PATH);
static const int MISSING_SETTINGS_DESC_ERROR_CODE = 8912;
QMetaObject::invokeMethod(QCoreApplication::instance(), "queuedQuit", Qt::QueuedConnection,
Q_ARG(QString, MISSING_SETTINGS_DESC_MSG),
Q_ARG(int, MISSING_SETTINGS_DESC_ERROR_CODE));
}
void DomainServerSettingsManager::processSettingsRequestPacket(QSharedPointer<ReceivedMessage> message) {