envMode now finally working

This commit is contained in:
Syping 2021-07-08 02:57:49 +02:00
parent 60f3937b7b
commit 684e3962de

View file

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