#ifndef SERVER_SERVER_HPP
#define SERVER_SERVER_HPP
+#include "zones-manager.hpp"
+
#include "utils/latch.hpp"
+#include "utils/signalfd.hpp"
+#include "utils/glib-loop.hpp"
+#include "ipc/epoll/event-poll.hpp"
+#include <atomic>
#include <string>
+#include <pthread.h>
-namespace security_containers {
+namespace vasum {
class Server {
public:
- Server(const std::string& configPath, bool runAsRoot = true);
- virtual ~Server();
-
- /**
- * Set needed caps, groups and drop root privileges.
- */
- static bool prepareEnvironment(const std::string& configPath, bool runAsRoot);
+ Server(const std::string& configPath);
/**
- * Starts all the containers and blocks until SIGINT, SIGTERM or SIGUSR1
+ * Starts all the zones and blocks until SIGINT, SIGTERM or SIGUSR1
*/
- void run();
+ void run(bool asRoot);
/**
* Reload the server by launching execve on itself if SIGUSR1 was sent to server.
* Equivalent of sending SIGINT or SIGTERM signal
*/
void terminate();
+
+ /**
+ * Check server runtime environment
+ */
+ static bool checkEnvironment();
+
private:
+ bool mIsRunning;
+ bool mIsUpdate;
std::string mConfigPath;
+ utils::ScopedGlibLoop loop;
+ ipc::epoll::EventPoll mEventPoll;
+ utils::SignalFD mSignalFD;
+ ZonesManager mZonesManager;
+ ::pthread_t mDispatchingThread;
+
+ /**
+ * Set needed caps, groups and drop root privileges.
+ */
+ static bool prepareEnvironment(const std::string& configPath, bool runAsRoot);
+
+ void handleUpdate();
+ void handleStop();
+
};
-} // namespace security_containers
+} // namespace vasum
#endif // SERVER_SERVER_HPP