From 392ecb0dae3e0f2c7a7bead747e85297af364cc6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 23 Sep 2016 16:41:44 -0700 Subject: [PATCH 1/5] Update interface to launch server --- interface/src/main.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 527b7f2331..3fc09636ed 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -29,6 +29,7 @@ #include "InterfaceLogging.h" #include "UserActivityLogger.h" #include "MainWindow.h" +#include #ifdef HAS_BUGSPLAT #include @@ -121,6 +122,27 @@ int main(int argc, const char* argv[]) { } } + QCommandLineParser parser; + QCommandLineOption runServer("runServer", "Whether to run the server"); + QCommandLineOption serverContentPath("serverContentPath", "Where to find server content", "serverContentPath"); + parser.addOption(runServer); + parser.addOption(serverContentPath); + parser.parse(arguments); + if (parser.isSet(runServer)) { + QString serverPath = QFileInfo(arguments[0]).path(); + serverPath += "/server-console/server-console.exe"; + //serverPath = "./server-console/server-console.exe"; + QStringList args; + if (parser.isSet(serverContentPath)) { + args << "--" << "--contentPath" << parser.value(serverContentPath); + } + qDebug() << "server path: " << serverPath << args; + qDebug() << QFileInfo(arguments[0]).path(); + qDebug() << QProcess::startDetached(serverPath, args); + + usleep(2000000); + } + QElapsedTimer startupTime; startupTime.start(); From fe6382d1b66ce3cb72c27e11c4790d9c0903264c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 23 Sep 2016 17:41:26 -0700 Subject: [PATCH 2/5] Update server content path to be relative --- interface/src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 3fc09636ed..7980d3de0f 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -134,7 +134,8 @@ int main(int argc, const char* argv[]) { //serverPath = "./server-console/server-console.exe"; QStringList args; if (parser.isSet(serverContentPath)) { - args << "--" << "--contentPath" << parser.value(serverContentPath); + QString serverContentPath = QFileInfo(arguments[0]).path() + "/" + parser.value(serverContentPath); + args << "--" << "--contentPath" << serverContentPath; } qDebug() << "server path: " << serverPath << args; qDebug() << QFileInfo(arguments[0]).path(); From 0aba1d3e54da35192a94eb51bf18ea1b7054726d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 26 Sep 2016 09:07:45 -0700 Subject: [PATCH 3/5] Fix server arguments causing crash on startup --- interface/src/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 7980d3de0f..8dd4414c6b 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -123,18 +123,18 @@ int main(int argc, const char* argv[]) { } QCommandLineParser parser; - QCommandLineOption runServer("runServer", "Whether to run the server"); - QCommandLineOption serverContentPath("serverContentPath", "Where to find server content", "serverContentPath"); - parser.addOption(runServer); - parser.addOption(serverContentPath); + QCommandLineOption runServerOption("runServer", "Whether to run the server"); + QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath"); + parser.addOption(runServerOption); + parser.addOption(serverContentPathOption); parser.parse(arguments); - if (parser.isSet(runServer)) { + if (parser.isSet(runServerOption)) { QString serverPath = QFileInfo(arguments[0]).path(); serverPath += "/server-console/server-console.exe"; //serverPath = "./server-console/server-console.exe"; QStringList args; - if (parser.isSet(serverContentPath)) { - QString serverContentPath = QFileInfo(arguments[0]).path() + "/" + parser.value(serverContentPath); + if (parser.isSet(serverContentPathOption)) { + QString serverContentPath = QFileInfo(arguments[0]).path() + "/" + parser.value(serverContentPathOption); args << "--" << "--contentPath" << serverContentPath; } qDebug() << "server path: " << serverPath << args; From 224c35d568caa23ffc1844c7fb66ee74ca2f0f6c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 3 Oct 2016 09:30:25 -0700 Subject: [PATCH 4/5] Clean up launch server in main.cpp --- interface/src/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 8dd4414c6b..c2bc10eefc 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -129,18 +129,20 @@ int main(int argc, const char* argv[]) { parser.addOption(serverContentPathOption); parser.parse(arguments); if (parser.isSet(runServerOption)) { - QString serverPath = QFileInfo(arguments[0]).path(); - serverPath += "/server-console/server-console.exe"; - //serverPath = "./server-console/server-console.exe"; + //QString serverPath = QFileInfo(arguments[0]).path(); + QString applicationDirPath = QCoreApplication::applicationDirPath(); + QString serverPath = "/server-console/server-console.exe"; + qDebug() << "Application dir path is: " << applicationDirPath; + qDebug() << "Server path is: " << serverPath; QStringList args; if (parser.isSet(serverContentPathOption)) { QString serverContentPath = QFileInfo(arguments[0]).path() + "/" + parser.value(serverContentPathOption); args << "--" << "--contentPath" << serverContentPath; } - qDebug() << "server path: " << serverPath << args; qDebug() << QFileInfo(arguments[0]).path(); qDebug() << QProcess::startDetached(serverPath, args); + // Sleep a short amount of time to give the server a chance to start usleep(2000000); } From ff8f45d36c3fa7a96fe77ee67865d6ece6be648d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 3 Oct 2016 15:45:19 -0700 Subject: [PATCH 5/5] Fix application directory path --- interface/src/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index c2bc10eefc..3c4a3fd77a 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -129,9 +129,8 @@ int main(int argc, const char* argv[]) { parser.addOption(serverContentPathOption); parser.parse(arguments); if (parser.isSet(runServerOption)) { - //QString serverPath = QFileInfo(arguments[0]).path(); - QString applicationDirPath = QCoreApplication::applicationDirPath(); - QString serverPath = "/server-console/server-console.exe"; + QString applicationDirPath = QFileInfo(arguments[0]).path(); + QString serverPath = applicationDirPath + "/server-console/server-console.exe"; qDebug() << "Application dir path is: " << applicationDirPath; qDebug() << "Server path is: " << serverPath; QStringList args;