Files
amnezia-client/service/server/main.cpp
T

34 lines
1.0 KiB
C++
Raw Normal View History

2020-12-16 06:02:22 +03:00
#include <QSettings>
#include <QDir>
2020-12-26 15:03:51 +03:00
#include "systemservice.h"
#include "log.h"
#include "defines.h"
#include "localserver.h"
2020-12-16 06:02:22 +03:00
int main(int argc, char **argv)
{
#if !defined(Q_OS_WIN)
// QtService stores service settings in SystemScope, which normally require root privileges.
// To allow testing this example as non-root, we change the directory of the SystemScope settings file.
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning("(Example uses dummy settings file: %s/QtSoftware.conf)", QDir::tempPath().toLatin1().constData());
#endif
2020-12-26 15:03:51 +03:00
Log::initialize();
if (argc == 2) {
qInfo() << "Started as console application";
QCoreApplication app(argc,argv);
LocalServer localServer(SERVICE_NAME);
if (!localServer.isRunning()) {
return -1;
}
return app.exec();
} else {
qInfo() << "Started as system service";
SystemService systemService(argc, argv);
return systemService.exec();
}
2020-12-16 06:02:22 +03:00
}