mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 14:10:40 +02:00
Update server-console to watch interface via pid rather than marker
This commit is contained in:
parent
6cc6cd3bf6
commit
a654bfa692
4 changed files with 28 additions and 6 deletions
|
@ -199,7 +199,7 @@ int main(int argc, const char* argv[]) {
|
||||||
bool serverContentPathOptionIsSet = parser.isSet(serverContentPathOption);
|
bool serverContentPathOptionIsSet = parser.isSet(serverContentPathOption);
|
||||||
QString serverContentPath = serverContentPathOptionIsSet ? parser.value(serverContentPathOption) : QString();
|
QString serverContentPath = serverContentPathOptionIsSet ? parser.value(serverContentPathOption) : QString();
|
||||||
if (runServer) {
|
if (runServer) {
|
||||||
SandboxUtils::runLocalSandbox(serverContentPath, true, RUNNING_MARKER_FILENAME, noUpdater);
|
SandboxUtils::runLocalSandbox(serverContentPath, true, noUpdater);
|
||||||
}
|
}
|
||||||
|
|
||||||
Application app(argc, const_cast<char**>(argv), startupTime, runningMarkerExisted);
|
Application app(argc, const_cast<char**>(argv), startupTime, runningMarkerExisted);
|
||||||
|
|
|
@ -52,9 +52,8 @@ bool readStatus(QByteArray statusData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void runLocalSandbox(QString contentPath, bool autoShutdown, QString runningMarkerName, bool noUpdater) {
|
void runLocalSandbox(QString contentPath, bool autoShutdown, bool noUpdater) {
|
||||||
QString serverPath = "./server-console/server-console.exe";
|
QString serverPath = "./server-console/server-console.exe";
|
||||||
qCDebug(networking) << "Running marker path is: " << runningMarkerName;
|
|
||||||
qCDebug(networking) << "Server path is: " << serverPath;
|
qCDebug(networking) << "Server path is: " << serverPath;
|
||||||
qCDebug(networking) << "autoShutdown: " << autoShutdown;
|
qCDebug(networking) << "autoShutdown: " << autoShutdown;
|
||||||
qCDebug(networking) << "noUpdater: " << noUpdater;
|
qCDebug(networking) << "noUpdater: " << noUpdater;
|
||||||
|
@ -74,8 +73,9 @@ void runLocalSandbox(QString contentPath, bool autoShutdown, QString runningMark
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoShutdown) {
|
if (autoShutdown) {
|
||||||
QString interfaceRunningStateFile = RunningMarker::getMarkerFilePath(runningMarkerName);
|
auto pid = qApp->applicationPid();
|
||||||
args << "--shutdownWatcher" << interfaceRunningStateFile;
|
qCDebug(networking) << "autoShutdown pid is" << pid;
|
||||||
|
args << "--watchProcessShutdown" << QString::number(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noUpdater) {
|
if (noUpdater) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace SandboxUtils {
|
||||||
|
|
||||||
QNetworkReply* getStatus();
|
QNetworkReply* getStatus();
|
||||||
bool readStatus(QByteArray statusData);
|
bool readStatus(QByteArray statusData);
|
||||||
void runLocalSandbox(QString contentPath, bool autoShutdown, QString runningMarkerName, bool noUpdater);
|
void runLocalSandbox(QString contentPath, bool autoShutdown, bool noUpdater);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_SandboxUtils_h
|
#endif // hifi_SandboxUtils_h
|
||||||
|
|
|
@ -821,6 +821,15 @@ for (var key in trayIcons) {
|
||||||
|
|
||||||
const notificationIcon = path.join(__dirname, '../resources/console-notification.png');
|
const notificationIcon = path.join(__dirname, '../resources/console-notification.png');
|
||||||
|
|
||||||
|
function isProcessRunning(pid) {
|
||||||
|
try {
|
||||||
|
running = process.kill(pid, 0);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function onContentLoaded() {
|
function onContentLoaded() {
|
||||||
// Disable splash window for now.
|
// Disable splash window for now.
|
||||||
// maybeShowSplash();
|
// maybeShowSplash();
|
||||||
|
@ -882,6 +891,19 @@ function onContentLoaded() {
|
||||||
startInterface();
|
startInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv.watchProcessShutdown) {
|
||||||
|
let pid = argv.watchProcessShutdown;
|
||||||
|
console.log("Watching process: ", pid);
|
||||||
|
let watchProcessInterval = setInterval(function() {
|
||||||
|
let isRunning = isProcessRunning(pid);
|
||||||
|
if (!isRunning) {
|
||||||
|
log.debug("Watched process is no longer running, shutting down");
|
||||||
|
clearTimeout(watchProcessInterval);
|
||||||
|
forcedShutdown();
|
||||||
|
}
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
// If we were launched with the shutdownWatcher option, then we need to watch for the interface app
|
// If we were launched with the shutdownWatcher option, then we need to watch for the interface app
|
||||||
// shutting down. The interface app will regularly update a running state file which we will check.
|
// shutting down. The interface app will regularly update a running state file which we will check.
|
||||||
// If the file doesn't exist or stops updating for a significant amount of time, we will shut down.
|
// If the file doesn't exist or stops updating for a significant amount of time, we will shut down.
|
||||||
|
|
Loading…
Reference in a new issue