Merge pull request #187 from YACReader/feature/fix-server-start-up-sequence

Fix launch sequence to avoid http port collisions
This commit is contained in:
Luis Ángel San Martín 2021-01-28 21:04:49 +01:00 committed by GitHub
commit 350234b099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 29 deletions

View File

@ -29,7 +29,7 @@
#define PICTUREFLOW_QT4 1
//interfaz al servidor
//Server interface
Startup *s;
using namespace QsLogging;
@ -215,8 +215,23 @@ int main(int argc, char **argv)
}
}
QLOG_INFO() << "YACReaderLibrary attempting to start";
logSystemAndConfig();
if (YACReaderLocalServer::isRunning()) //only a single instance of YACReaderLibrary is allowed
{
QLOG_WARN() << "another instance of YACReaderLibrary is running";
#ifdef Q_OS_WIN
logger.shutDownLoggerThread();
#endif
return 0;
}
QLOG_INFO() << "YACReaderLibrary starting";
#ifdef SERVER_RELEASE
QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat);
settings->beginGroup("libraryConfig");
s = new Startup();
@ -225,19 +240,6 @@ int main(int argc, char **argv)
s->start();
}
#endif
QLOG_INFO() << "YACReaderLibrary attempting to start";
logSystemAndConfig();
if (YACReaderLocalServer::isRunning()) //s<>lo se permite una instancia de YACReaderLibrary
{
QLOG_WARN() << "another instance of YACReaderLibrary is running";
#ifdef Q_OS_WIN
logger.shutDownLoggerThread();
#endif
return 0;
}
QLOG_INFO() << "YACReaderLibrary starting";
auto localServer = new YACReaderLocalServer();

View File

@ -175,6 +175,21 @@ int main(int argc, char **argv)
qRegisterMetaType<ComicDB>("ComicDB");
QLOG_INFO() << "YACReaderLibraryServer attempting to start";
logSystemAndConfig();
if (YACReaderLocalServer::isRunning()) // allow one server instance
{
QLOG_WARN() << "another instance of YACReaderLibrary is running";
#ifdef Q_OS_WIN
logger.shutDownLoggerThread();
#endif
return 0;
}
QLOG_INFO() << "YACReaderLibrary starting";
QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/" + QCoreApplication::applicationName() + ".ini", QSettings::IniFormat);
settings->beginGroup("libraryConfig");
@ -195,22 +210,9 @@ int main(int argc, char **argv)
s->start();
}
QLOG_INFO() << "YACReaderLibraryServer attempting to start";
logSystemAndConfig();
if (YACReaderLocalServer::isRunning()) // allow one server instance
{
QLOG_WARN() << "another instance of YACReaderLibrary is running";
#ifdef Q_OS_WIN
logger.shutDownLoggerThread();
#endif
return 0;
}
QLOG_INFO() << "YACReaderLibrary starting";
QLOG_INFO() << "Running on port" << s->getPort();
//Update libraries to now versions
//Update libraries to new versions
LibrariesUpdater updater;
updater.updateIfNeeded();