UniSet @VERSION@
ConfigLoader.h
1/*
2 * Copyright (c) 2026 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 */
8// -------------------------------------------------------------------------
9#ifndef ConfigLoader_H_
10#define ConfigLoader_H_
11// -------------------------------------------------------------------------
12#include <memory>
13#include <string>
14#include <vector>
15#include <map>
16#include "ProcessInfo.h"
17#include "UniXML.h"
18#include "Configuration.h"
19// -------------------------------------------------------------------------
20namespace uniset
21{
44 {
45 public:
47 {
48 std::string name;
49 size_t healthCheckInterval_msec = 5000;
50 size_t restartDelay_msec = 1000;
51 size_t maxRestartDelay_msec = 30000; // Max delay for exponential backoff
52 size_t restartWindow_msec = 60000;
53 int maxRestarts = 0; // 0 = infinite restarts
54 int httpPort = 0; // 0 = disabled
55
56 std::vector<std::string> commonArgs; // Common args prepended to all processes
57 std::string defaultReadyCheck; // Default ready check for processes without explicit one
58
59 std::vector<ProcessGroup> groups;
60 std::map<std::string, ProcessInfo> processes;
61 std::map<std::string, std::string> environment;
62
63 std::string sharedMemoryName; // Auto-detected SharedMemory process name
64 };
65
66 ConfigLoader() = default;
67
74 LauncherConfig load(const std::string& xmlFile,
75 const std::string& launcherName = "");
76
83 LauncherConfig load(const std::shared_ptr<UniXML>& xml,
84 const std::string& launcherName = "");
85
92 static bool needsNamingService(const std::shared_ptr<Configuration>& conf);
93
94 private:
95 void loadGroups(xmlNode* launcherNode, LauncherConfig& config);
96 void loadProcess(xmlNode* processNode, const std::string& groupName,
97 LauncherConfig& config);
98 void loadEnvironment(xmlNode* launcherNode, LauncherConfig& config);
99
100 std::vector<std::string> parseArgs(const std::string& argsStr);
101 std::set<std::string> parseNodeFilter(const std::string& filterStr);
102 };
103
104} // end of namespace uniset
105// -------------------------------------------------------------------------
106#endif // ConfigLoader_H_
107// -------------------------------------------------------------------------
Definition ConfigLoader.h:44
LauncherConfig load(const std::string &xmlFile, const std::string &launcherName="")
Definition ConfigLoader.cc:18
static bool needsNamingService(const std::shared_ptr< Configuration > &conf)
Definition ConfigLoader.cc:556
Definition AccessConfig.h:30
Definition ConfigLoader.h:47