envMode now finally working

This commit is contained in:
Syping 2021-07-08 02:57:49 +02:00
parent 60f3937b7b
commit 684e3962de
1 changed files with 20 additions and 16 deletions

View File

@ -135,7 +135,7 @@ int main(int argc, char *argv[])
{ {
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
a.setApplicationName("Server Manager Subprocess"); a.setApplicationName("Server Manager Subprocess");
a.setApplicationVersion("0.5"); a.setApplicationVersion("0.5.1");
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
catchUnixSignals({SIGINT, SIGHUP, SIGQUIT, SIGTERM}); catchUnixSignals({SIGINT, SIGHUP, SIGQUIT, SIGTERM});
@ -164,6 +164,7 @@ int main(int argc, char *argv[])
if (unlikely(envEnvironmentMode == "1" || envEnvironmentMode.toLower() == "true")) { if (unlikely(envEnvironmentMode == "1" || envEnvironmentMode.toLower() == "true")) {
if (likely(envExecutable.isEmpty() && envArguments.isEmpty())) { if (likely(envExecutable.isEmpty() && envArguments.isEmpty())) {
QStringList arguments = a.arguments(); QStringList arguments = a.arguments();
arguments.removeFirst();
executable = arguments.takeFirst(); executable = arguments.takeFirst();
argumentList = arguments; argumentList = arguments;
} }
@ -227,13 +228,14 @@ int main(int argc, char *argv[])
if (unlikely(!envRemotePort.isEmpty())) { if (unlikely(!envRemotePort.isEmpty())) {
bool ok; bool ok;
rport = envRemotePort.toUShort(&ok); const quint16 _rport = envRemotePort.toUShort(&ok);
if (!ok) { if (ok) {
QTextStream(stderr) << "WebSockets port is not valid in environment!" << smsub_endl; rport = _rport;
return 1; rportSet = true;
} }
else { else {
rportSet = true; QTextStream(stderr) << "WebSockets port is not valid in environment!" << smsub_endl;
return 1;
} }
} }
} }
@ -448,24 +450,26 @@ int main(int argc, char *argv[])
if (unlikely(commandLineParser.isSet(subprocessRemotePort))) { if (unlikely(commandLineParser.isSet(subprocessRemotePort))) {
bool ok; bool ok;
rport = commandLineParser.value(subprocessRemotePort).toUShort(&ok); const quint16 _rport = commandLineParser.value(subprocessRemotePort).toUShort(&ok);
if (!ok) { if (ok) {
QTextStream(stderr) << "WebSockets port is not valid in arguments!" << smsub_endl; rport = _rport;
return 1; rportSet = true;
} }
else { else {
rportSet = true; QTextStream(stderr) << "WebSockets port is not valid in arguments!" << smsub_endl;
return 1;
} }
} }
else if (!envRemotePort.isEmpty()) { else if (!envRemotePort.isEmpty()) {
bool ok; bool ok;
rport = envRemotePort.toUShort(&ok); const quint16 _rport = envRemotePort.toUShort(&ok);
if (!ok) { if (ok) {
QTextStream(stderr) << "WebSockets port is not valid in environment!" << smsub_endl; rport = _rport;
return 1; rportSet = true;
} }
else { else {
rportSet = true; QTextStream(stderr) << "WebSockets port is not valid in arguments!" << smsub_endl;
return 1;
} }
} }
} }