UniSet @VERSION@
ProcessTemplate.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 ProcessTemplate_H_
10#define ProcessTemplate_H_
11// -------------------------------------------------------------------------
12#include <string>
13#include <vector>
14#include <map>
15// -------------------------------------------------------------------------
16namespace uniset
17{
23 {
24 std::string type;
25 std::string command;
26 std::string argsPattern;
27 std::string readyCheck;
28 size_t readyTimeout_msec = 10000;
29 size_t checkTimeout_msec = 1000;
30 size_t checkPause_msec = 1000;
31 int group = 2;
32 bool critical = false;
33 bool needsSharedMemory = true;
34 std::vector<std::string> prefixes;
35 };
36
41 {
42 public:
44
50 const ProcessTemplate* findByType(const std::string& type) const;
51
57 const ProcessTemplate* findByPrefix(const std::string& name) const;
58
64 std::string detectType(const std::string& name) const;
65
70 void registerTemplate(const ProcessTemplate& tmpl);
71
75 const std::vector<ProcessTemplate>& templates() const
76 {
77 return templates_;
78 }
79
86 static std::string expandPattern(const std::string& pattern, const std::string& name);
87
88 private:
89 void registerBuiltinTemplates();
90
91 std::vector<ProcessTemplate> templates_;
92 std::map<std::string, size_t> typeIndex_; // type -> index in templates_
93 };
94
98 ProcessTemplateRegistry& getProcessTemplateRegistry();
99
100} // end of namespace uniset
101// -------------------------------------------------------------------------
102#endif // ProcessTemplate_H_
103// -------------------------------------------------------------------------
Definition ProcessTemplate.h:41
const std::vector< ProcessTemplate > & templates() const
Definition ProcessTemplate.h:75
const ProcessTemplate * findByPrefix(const std::string &name) const
Definition ProcessTemplate.cc:219
static std::string expandPattern(const std::string &pattern, const std::string &name)
Definition ProcessTemplate.cc:251
void registerTemplate(const ProcessTemplate &tmpl)
Definition ProcessTemplate.cc:244
const ProcessTemplate * findByType(const std::string &type) const
Definition ProcessTemplate.cc:209
std::string detectType(const std::string &name) const
Definition ProcessTemplate.cc:234
Definition AccessConfig.h:30
ProcessTemplateRegistry & getProcessTemplateRegistry()
Definition ProcessTemplate.cc:269
Definition ProcessTemplate.h:23
int group
Startup group (0=naming, 1=sharedmemory, 2=exchanges)
Definition ProcessTemplate.h:31
size_t checkTimeout_msec
Single check timeout (for health monitoring)
Definition ProcessTemplate.h:29
std::string readyCheck
Ready check pattern (${name} is replaced, empty = no check)
Definition ProcessTemplate.h:27
bool needsSharedMemory
Add –smemory-id automatically.
Definition ProcessTemplate.h:33
std::string argsPattern
Arguments pattern (${name} is replaced with process name)
Definition ProcessTemplate.h:26
std::string command
Command to run (uniset2-smemory, etc.)
Definition ProcessTemplate.h:25
size_t readyTimeout_msec
Ready check timeout (total wait time)
Definition ProcessTemplate.h:28
bool critical
Process is critical by default.
Definition ProcessTemplate.h:32
std::string type
Type identifier (SharedMemory, UNetExchange, etc.)
Definition ProcessTemplate.h:24
std::vector< std::string > prefixes
Name prefixes for auto-detection.
Definition ProcessTemplate.h:34
size_t checkPause_msec
Pause between checks.
Definition ProcessTemplate.h:30