mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
only start the server if the command 'start' is used
This commit is contained in:
parent
ea625eac29
commit
1ceda5b9d7
@ -128,7 +128,71 @@ int main( int argc, char ** argv )
|
|||||||
|
|
||||||
if(command == "start")
|
if(command == "start")
|
||||||
{
|
{
|
||||||
|
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
||||||
|
QDir().mkpath(YACReader::getSettingsPath());
|
||||||
|
|
||||||
|
Logger& logger = Logger::instance();
|
||||||
|
logger.setLoggingLevel(QsLogging::TraceLevel);
|
||||||
|
|
||||||
|
DestinationPtr fileDestination(DestinationFactory::MakeFileDestination(
|
||||||
|
destLog, EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2)));
|
||||||
|
DestinationPtr debugDestination(DestinationFactory::MakeDebugOutputDestination());
|
||||||
|
logger.addDestination(debugDestination);
|
||||||
|
logger.addDestination(fileDestination);
|
||||||
|
|
||||||
|
QTranslator translator;
|
||||||
|
QString sufix = QLocale::system().name();
|
||||||
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
|
translator.load(QString(DATADIR)+"/yacreader/languages/yacreaderlibrary_"+sufix);
|
||||||
|
#else
|
||||||
|
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
||||||
|
#endif
|
||||||
|
app->installTranslator(&translator);
|
||||||
|
|
||||||
|
QTranslator viewerTranslator;
|
||||||
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
|
viewerTranslator.load(QString(DATADIR)+"/yacreader/languages/yacreader_"+sufix);
|
||||||
|
#else
|
||||||
|
viewerTranslator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
||||||
|
#endif
|
||||||
|
app->installTranslator(&viewerTranslator);
|
||||||
|
|
||||||
|
qRegisterMetaType<ComicDB>("ComicDB");
|
||||||
|
|
||||||
|
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini",QSettings::IniFormat);
|
||||||
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
|
//server
|
||||||
|
Startup *s = new Startup();
|
||||||
|
s->start();
|
||||||
|
|
||||||
|
QLOG_INFO() << "YACReaderLibraryServer attempting to start";
|
||||||
|
|
||||||
|
logSystemAndConfig();
|
||||||
|
|
||||||
|
if(YACReaderLocalServer::isRunning()) //s�lo se permite una instancia de YACReaderLibrary
|
||||||
|
{
|
||||||
|
QLOG_WARN() << "another instance of YACReaderLibrary is running";
|
||||||
|
QsLogging::Logger::destroyInstance();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
QLOG_INFO() << "YACReaderLibrary starting";
|
||||||
|
|
||||||
|
YACReaderLocalServer * localServer = new YACReaderLocalServer();
|
||||||
|
|
||||||
|
int ret = app->exec();
|
||||||
|
|
||||||
|
QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret;
|
||||||
|
|
||||||
|
//shutdown
|
||||||
|
s->stop();
|
||||||
|
delete s;
|
||||||
|
localServer->close();
|
||||||
|
delete localServer;
|
||||||
|
|
||||||
|
QsLogging::Logger::destroyInstance();
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
else if(command == "create-library")
|
else if(command == "create-library")
|
||||||
{
|
{
|
||||||
@ -196,71 +260,7 @@ int main( int argc, char ** argv )
|
|||||||
else //error
|
else //error
|
||||||
{
|
{
|
||||||
parser.showHelp();
|
parser.showHelp();
|
||||||
}
|
|
||||||
|
|
||||||
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
|
||||||
QDir().mkpath(YACReader::getSettingsPath());
|
|
||||||
|
|
||||||
Logger& logger = Logger::instance();
|
|
||||||
logger.setLoggingLevel(QsLogging::TraceLevel);
|
|
||||||
|
|
||||||
DestinationPtr fileDestination(DestinationFactory::MakeFileDestination(
|
|
||||||
destLog, EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2)));
|
|
||||||
DestinationPtr debugDestination(DestinationFactory::MakeDebugOutputDestination());
|
|
||||||
logger.addDestination(debugDestination);
|
|
||||||
logger.addDestination(fileDestination);
|
|
||||||
|
|
||||||
QTranslator translator;
|
|
||||||
QString sufix = QLocale::system().name();
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
|
||||||
translator.load(QString(DATADIR)+"/yacreader/languages/yacreaderlibrary_"+sufix);
|
|
||||||
#else
|
|
||||||
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
|
||||||
#endif
|
|
||||||
app->installTranslator(&translator);
|
|
||||||
|
|
||||||
QTranslator viewerTranslator;
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
|
||||||
viewerTranslator.load(QString(DATADIR)+"/yacreader/languages/yacreader_"+sufix);
|
|
||||||
#else
|
|
||||||
viewerTranslator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
|
||||||
#endif
|
|
||||||
app->installTranslator(&viewerTranslator);
|
|
||||||
|
|
||||||
qRegisterMetaType<ComicDB>("ComicDB");
|
|
||||||
|
|
||||||
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini",QSettings::IniFormat);
|
|
||||||
settings->beginGroup("libraryConfig");
|
|
||||||
|
|
||||||
//server
|
|
||||||
Startup *s = new Startup();
|
|
||||||
s->start();
|
|
||||||
|
|
||||||
QLOG_INFO() << "YACReaderLibraryServer attempting to start";
|
|
||||||
|
|
||||||
logSystemAndConfig();
|
|
||||||
|
|
||||||
if(YACReaderLocalServer::isRunning()) //s�lo se permite una instancia de YACReaderLibrary
|
|
||||||
{
|
|
||||||
QLOG_WARN() << "another instance of YACReaderLibrary is running";
|
|
||||||
QsLogging::Logger::destroyInstance();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
QLOG_INFO() << "YACReaderLibrary starting";
|
|
||||||
|
|
||||||
YACReaderLocalServer * localServer = new YACReaderLocalServer();
|
|
||||||
|
|
||||||
int ret = app->exec();
|
|
||||||
|
|
||||||
QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret;
|
|
||||||
|
|
||||||
//shutdown
|
|
||||||
s->stop();
|
|
||||||
delete s;
|
|
||||||
localServer->close();
|
|
||||||
delete localServer;
|
|
||||||
|
|
||||||
QsLogging::Logger::destroyInstance();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user