MCPcopy Create free account
hub / github.com/YACReader/yacreader / start

Method start

YACReaderLibrary/server/yacreader_http_server.cpp:30–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28using stefanfrings::StaticFileController;
29
30void YACReaderHttpServer::start(quint16 port)
31{
32 // Initialize the core application
33 QCoreApplication *app = QCoreApplication::instance();
34 QString configFileName = YACReader::getSettingsPath() + "/" + QCoreApplication::applicationName() + ".ini";
35
36 Static::yacreaderSessionStore = new YACReaderHttpSessionStore(app);
37
38 // Configure static file controller
39 auto fileSettings = new QSettings(configFileName, QSettings::IniFormat, app);
40 fileSettings->beginGroup("docroot");
41
42 QString basedocroot = "./server/docroot";
43 QString docroot;
44
45#if defined Q_OS_UNIX && !defined Q_OS_MACOS
46 QFileInfo configFile(QString(DATADIR) + "/yacreader");
47 docroot = QFileInfo(QString(DATADIR) + "/yacreader", basedocroot).absoluteFilePath();
48#else
49 QFileInfo configFile(QCoreApplication::applicationDirPath());
50 docroot = QFileInfo(QCoreApplication::applicationDirPath(), basedocroot).absoluteFilePath();
51#endif
52
53 // The WebUI is shipped with the application, so its document root must
54 // follow the currently running binary. Persisting the generated path made
55 // it point to stale build and installation directories after an upgrade.
56 // TODO: do we really want to keep using this setting at all?
57 fileSettings->setValue("path", docroot);
58
59 Static::staticFileController = new StaticFileController(fileSettings, app);
60
61 // Configure and start the TCP listener
62 qDebug("ServiceHelper: Starting service");
63 auto listenerSettings = new QSettings(configFileName, QSettings::IniFormat, app);
64 listenerSettings->beginGroup("listener");
65
66 if (listenerSettings->value("maxRequestSize").isNull())
67 listenerSettings->setValue("maxRequestSize", "32000000");
68
69 if (listenerSettings->value("maxMultiPartSize").isNull())
70 listenerSettings->setValue("maxMultiPartSize", "32000000");
71
72 if (listenerSettings->value("cleanupInterval").isNull())
73 listenerSettings->setValue("cleanupInterval", 10000);
74
75 if (listenerSettings->value("maxThreads").isNull())
76 listenerSettings->setValue("maxThreads", 1000);
77
78 if (listenerSettings->value("minThreads").isNull())
79 listenerSettings->setValue("minThreads", 50);
80
81 if (listenerSettings->value("port").isNull())
82 listenerSettings->setValue("port", 8080);
83
84 // start with a temporary port
85 if (port != 0) {
86 // cache saved port
87 if (!listenerSettings->contains("cachedPort")) {

Callers 15

mainFunction · 0.80
BusyIndicatorMethod · 0.80
dragMoveEventMethod · 0.80
ScrollManagementMethod · 0.80
getMethod · 0.80
runMethod · 0.80
renderMethod · 0.80
createLibraryMethod · 0.80
updateLibraryMethod · 0.80
startFunction · 0.80
flashMethod · 0.80
scheduleDecodeMethod · 0.80

Calls 6

setValueMethod · 0.80
isListeningMethod · 0.80
QStringClass · 0.50
containsMethod · 0.45
removeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected