#pragma once #include #include 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& 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