Files
moloapp/src/cli/dev/reloader.hpp
T
retoor 3c4334cec9 feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security,
data, app, realtime, supervisor, clients, CLI, example plus
enterprise tenancy, audit, operability, governance,
supplychain. Postgres via docker compose for tests.
2026-10-23 18:20:04 +02:00

31 lines
769 B
C++

#pragma once
#include <string>
#include <vector>
namespace molo::dev {
// Runs `make`, supervises the child process, and computes crash backoff.
// Dumb by design: no state is preserved across restarts.
class Reloader {
public:
Reloader();
~Reloader();
bool run_make(const std::string& make_args, int timeout_sec, std::string& error);
bool start_child(const std::vector<std::string>& argv, std::string& error);
void stop_child(int grace_sec);
bool child_running() const;
// Backoff: 1s, 2s, 4s ... capped at kBackoffMaxSec.
static int backoff_for(int consecutive_failures);
void note_exit(bool clean);
int consecutive_failures() const { return failures_; }
private:
long child_pid_ = -1;
int failures_ = 0;
};
} // namespace molo::dev