Kylin/Universal/ProcessUtility.h
2023-07-25 10:40:14 +08:00

55 lines
1.6 KiB
C++

#ifndef DOCKERUTILITY_H
#define DOCKERUTILITY_H
#include <optional>
#include <string>
#include <string_view>
#include <system_error>
/**
* @brief used when app run on the native machine
*/
class DockerUtility {
public:
void stop(const std::string &nameFilter);
static bool supervisorStatus(std::string_view container, const std::string &module);
template <typename... Args>
static void runScript(std::string_view container, const std::string &script, Args &&...scriptArgs);
static bool running(std::string_view container, std::error_code &error);
static void executeBashCommand(const std::string &command);
static void execute(const std::string_view &container, const std::string_view &command);
static void kill(const std::string &nameFilter);
static bool containerExisted(const std::string_view &name);
/**
* @brief supervisorctl
* @param module
* @param isStart true:start,false:stop
*/
static void supervisorctl(const std::string_view &container, const std::string &module, bool isStart);
private:
DockerUtility() = default;
};
class NativeUtility {
public:
using ShellCommand = std::true_type;
template <typename... Args>
static void runScript(const std::string &script, Args &&...scriptArgs);
static bool processRunning(const std::string &nameFilter);
static std::string currentExecutable();
static std::string executableDirectory();
static std::string applicationDataDirectory(bool create = true);
static std::string homeDirectory();
private:
NativeUtility() = default;
};
#include "ProcessUtility.inl"
#endif // DOCKERUTILITY_H