mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 22:59:02 +02:00
Preliminary work on AC auto cleanup
This commit is contained in:
parent
3a096381ce
commit
a66e1148ba
4 changed files with 28 additions and 0 deletions
|
@ -24,6 +24,12 @@
|
|||
#include <QtCore/QDir>
|
||||
#include <QtCore/QStandardPaths>
|
||||
|
||||
VOID CALLBACK parentDiedCallback(PVOID lpParameter, BOOLEAN timerOrWaitFired) {
|
||||
if (!timerOrWaitFired) {
|
||||
qDebug() << "Parent process died, quitting";
|
||||
qApp->quit();
|
||||
}
|
||||
}
|
||||
|
||||
AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||
QCoreApplication(argc, argv)
|
||||
|
@ -87,6 +93,9 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
|||
const QCommandLineOption logDirectoryOption(ASSIGNMENT_LOG_DIRECTORY, "directory to store logs", "log-directory");
|
||||
parser.addOption(logDirectoryOption);
|
||||
|
||||
const QCommandLineOption parentPIDOption(ASSIGNMENT_PARENT_PID, "PID of the parent process", "parent-pid");
|
||||
parser.addOption(parentPIDOption);
|
||||
|
||||
if (!parser.parse(QCoreApplication::arguments())) {
|
||||
qCritical() << parser.errorText() << endl;
|
||||
parser.showHelp();
|
||||
|
@ -203,6 +212,19 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
|||
}
|
||||
}
|
||||
|
||||
DWORD processID;
|
||||
HANDLE procHandle;
|
||||
HANDLE newHandle;
|
||||
if (parser.isSet(parentPIDOption)) {
|
||||
bool ok = false;
|
||||
processID = parser.value(parentPIDOption).toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
procHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
|
||||
RegisterWaitForSingleObject(&newHandle, procHandle, parentDiedCallback, NULL, INFINITE, WT_EXECUTEONLYONCE);
|
||||
}
|
||||
}
|
||||
|
||||
QThread::currentThread()->setObjectName("main thread");
|
||||
|
||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
|
|
|
@ -27,6 +27,7 @@ const QString ASSIGNMENT_MAX_FORKS_OPTION = "max";
|
|||
const QString ASSIGNMENT_CLIENT_MONITOR_PORT_OPTION = "monitor-port";
|
||||
const QString ASSIGNMENT_HTTP_STATUS_PORT = "http-status-port";
|
||||
const QString ASSIGNMENT_LOG_DIRECTORY = "log-directory";
|
||||
const QString ASSIGNMENT_PARENT_PID = "parent-pid";
|
||||
|
||||
class AssignmentClientApp : public QCoreApplication {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -159,6 +159,10 @@ void AssignmentClientMonitor::spawnChildClient() {
|
|||
// for now they simply talk to us on localhost
|
||||
_childArguments.append("--" + ASSIGNMENT_CLIENT_MONITOR_PORT_OPTION);
|
||||
_childArguments.append(QString::number(DependencyManager::get<NodeList>()->getLocalSockAddr().getPort()));
|
||||
|
||||
|
||||
_childArguments.append("--" + ASSIGNMENT_PARENT_PID);
|
||||
_childArguments.append(QString::number(QCoreApplication::applicationPid()));
|
||||
|
||||
QString nowString, stdoutFilenameTemp, stderrFilenameTemp, stdoutPathTemp, stderrPathTemp;
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ Process.prototype = extend(Process.prototype, {
|
|||
detached: false,
|
||||
stdio: ['ignore', logStdout, logStderr]
|
||||
});
|
||||
log.debug("Spawned " + this.command + " with pid " + this.child.pid);
|
||||
} catch (e) {
|
||||
log.debug("Got error starting child process for " + this.name, e);
|
||||
this.child = null;
|
||||
|
|
Loading…
Reference in a new issue