/* This file is part of FlashMQ (https://www.flashmq.org) Copyright (C) 2021 Wiebe Cazemier FlashMQ is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3. FlashMQ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with FlashMQ. If not, see . */ #ifndef MAINAPP_H #define MAINAPP_H #include #include #include #include #include #include #include #include #include #include #include #include "forward_declarations.h" #include "utils.h" #include "threaddata.h" #include "client.h" #include "mqttpacket.h" #include "subscriptionstore.h" #include "configfileparser.h" #include "timer.h" #include "scopedsocket.h" #include "oneinstancelock.h" class MainApp { static MainApp *instance; int num_threads = 0; bool started = false; bool running = true; std::vector> threads; std::shared_ptr subscriptionStore; std::unique_ptr confFileParser; std::forward_list> taskQueue; int epollFdAccept = -1; int taskEventFd = -1; std::mutex eventMutex; Timer timer; std::shared_ptr settings; std::list> listeners; std::mutex quitMutex; std::string fuzzFilePath; OneInstanceLock oneInstanceLock; Logger *logger = Logger::getInstance(); void setlimits(rlim_t nofile); void loadConfig(); void reloadConfig(); static void doHelp(const char *arg); static void showLicense(); std::list createListenSocket(const std::shared_ptr &listener); void wakeUpThread(); void queueKeepAliveCheckAtAllThreads(); void setFuzzFile(const std::string &fuzzFilePath); MainApp(const std::string &configFilePath); public: MainApp(const MainApp &rhs) = delete; MainApp(MainApp &&rhs) = delete; ~MainApp(); static MainApp *getMainApp(); static void initMainApp(int argc, char *argv[]); void start(); void quit(); bool getStarted() const {return started;} static void testConfig(); void queueConfigReload(); void queueCleanup(); }; #endif // MAINAPP_H