lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lintel::Process Class Reference

#include <Process.h>

Public Member Functions

 Process (std::filesystem::path path, std::vector< std::string > args, std::string configName="")
 
void addOnStartEvent (std::shared_ptr< std::function< void(const Process &)> > onStart)
 
void addOnStopEvent (std::shared_ptr< std::function< void(const Process &)> > onStop)
 
void addOnRestartEvent (std::shared_ptr< std::function< void(const Process &)> > onRestart)
 
void addOnTerminateEvent (std::shared_ptr< std::function< void(const Process &)> > onTerminate)
 
void addOnFinishEvent (std::shared_ptr< std::function< void(const Process &)> > onFinish)
 
void enableAutoStart (int maxAutoRestarts=-1)
 
void disableAutoStart ()
 
void increaseRestarts ()
 
void resetRestarts ()
 
int currentRestarts () const
 
const std::string & getId () const
 
const std::filesystem::path & getPath () const
 
bool isAutoRestart () const
 
int getMaxAutoRestarts () const
 
const std::vector< std::string > & getArgs () const
 
const std::string & getConfigName () const
 
void setRestartDelay (std::chrono::milliseconds delay)
 
std::chrono::milliseconds getRestartDelay () const
 
void setRestartDelayMax (std::chrono::milliseconds delayMax)
 
std::chrono::milliseconds getRestartDelayMax () const
 
void setMinUptime (std::chrono::milliseconds minUptime)
 
std::chrono::milliseconds getMinUptime () const
 
void setMaxRestartRate (int maxRestartRate)
 
int getMaxRestartRate () const
 
void setRestartWindow (std::chrono::milliseconds restartWindow)
 
std::chrono::milliseconds getRestartWindow () const
 
void setRestartInterval (std::chrono::milliseconds restartInterval)
 
std::chrono::milliseconds getRestartInterval () const
 
void setActiveFromHour (std::optional< int32_t > activeFromHour)
 
std::optional< int32_t > getActiveFromHour () const
 
void setActiveToHour (std::optional< int32_t > activeToHour)
 
std::optional< int32_t > getActiveToHour () const
 
bool hasActiveWindow () const
 
bool inActiveWindow () const
 
void setCpuNotify (std::optional< double > cpuNotify)
 
std::optional< double > getCpuNotify () const
 
void setMemoryNotify (std::optional< uint64_t > memoryNotify)
 
std::optional< uint64_t > getMemoryNotify () const
 
void onStart () const
 
void onStop () const
 
void onRestart () const
 
void onTerminate () const
 
void onFinish () const
 

Detailed Description

Represents a managed process with lifecycle callbacks, auto-restart capability and configurable automation policy (backoff, rate limit, periodic restart, active time window and resource notify thresholds).

Constructor & Destructor Documentation

◆ Process()

lintel::Process::Process ( std::filesystem::path  path,
std::vector< std::string >  args,
std::string  configName = "" 
)
explicit

Constructor.

Parameters
pathpath to the executable
argscommand-line arguments
configNamebootstrap config name used by the child process (empty = inherit)

Member Function Documentation

◆ addOnFinishEvent()

void lintel::Process::addOnFinishEvent ( std::shared_ptr< std::function< void(const Process &)> >  onFinish)
Parameters
onFinishcallback invoked when the process finishes

◆ addOnRestartEvent()

void lintel::Process::addOnRestartEvent ( std::shared_ptr< std::function< void(const Process &)> >  onRestart)
Parameters
onRestartcallback invoked when the process restarts

◆ addOnStartEvent()

void lintel::Process::addOnStartEvent ( std::shared_ptr< std::function< void(const Process &)> >  onStart)
Parameters
onStartcallback invoked when the process starts

◆ addOnStopEvent()

void lintel::Process::addOnStopEvent ( std::shared_ptr< std::function< void(const Process &)> >  onStop)
Parameters
onStopcallback invoked when the process stops

◆ addOnTerminateEvent()

void lintel::Process::addOnTerminateEvent ( std::shared_ptr< std::function< void(const Process &)> >  onTerminate)
Parameters
onTerminatecallback invoked when the process is terminated

◆ currentRestarts()

int lintel::Process::currentRestarts ( ) const
Returns
current number of restarts

◆ disableAutoStart()

void lintel::Process::disableAutoStart ( )

Disable auto-restart for the process.

◆ enableAutoStart()

void lintel::Process::enableAutoStart ( int  maxAutoRestarts = -1)

Enable auto-restart for the process.

Parameters
maxAutoRestartsmaximum number of restarts (-1 for unlimited)

◆ getActiveFromHour()

std::optional< int32_t > lintel::Process::getActiveFromHour ( ) const
Returns
active window start hour (0-23), nullopt if disabled

◆ getActiveToHour()

std::optional< int32_t > lintel::Process::getActiveToHour ( ) const
Returns
active window end hour (0-23), nullopt if disabled

◆ getArgs()

const std::vector< std::string > & lintel::Process::getArgs ( ) const
Returns
command-line arguments

◆ getConfigName()

const std::string & lintel::Process::getConfigName ( ) const
Returns
bootstrap config name of the child process (empty = inherit)

◆ getCpuNotify()

std::optional< double > lintel::Process::getCpuNotify ( ) const
Returns
CPU usage percentage threshold that triggers a notify

◆ getId()

const std::string & lintel::Process::getId ( ) const
Returns
process UUID

◆ getMaxAutoRestarts()

int lintel::Process::getMaxAutoRestarts ( ) const
Returns
maximum number of auto-restarts

◆ getMaxRestartRate()

int lintel::Process::getMaxRestartRate ( ) const
Returns
maximum restart count within the rate window

◆ getMemoryNotify()

std::optional< uint64_t > lintel::Process::getMemoryNotify ( ) const
Returns
memory usage threshold in bytes that triggers a notify

◆ getMinUptime()

std::chrono::milliseconds lintel::Process::getMinUptime ( ) const
Returns
minimum uptime to consider a crash healthy (0 = always count)

◆ getPath()

const std::filesystem::path & lintel::Process::getPath ( ) const
Returns
path to the executable

◆ getRestartDelay()

std::chrono::milliseconds lintel::Process::getRestartDelay ( ) const
Returns
base backoff delay before the next auto-restart

◆ getRestartDelayMax()

std::chrono::milliseconds lintel::Process::getRestartDelayMax ( ) const
Returns
maximum (capped) backoff delay

◆ getRestartInterval()

std::chrono::milliseconds lintel::Process::getRestartInterval ( ) const
Returns
periodic restart interval (0 = disabled)

◆ getRestartWindow()

std::chrono::milliseconds lintel::Process::getRestartWindow ( ) const
Returns
time window over which the restart rate is evaluated

◆ hasActiveWindow()

bool lintel::Process::hasActiveWindow ( ) const
Returns
true if an active time window is configured

◆ inActiveWindow()

bool lintel::Process::inActiveWindow ( ) const
Returns
true if the current time is inside the configured active window

◆ increaseRestarts()

void lintel::Process::increaseRestarts ( )

Increment the restart counter.

◆ isAutoRestart()

bool lintel::Process::isAutoRestart ( ) const
Returns
true if auto-restart is enabled

◆ onFinish()

void lintel::Process::onFinish ( ) const

Trigger the onFinish event.

◆ onRestart()

void lintel::Process::onRestart ( ) const

Trigger the onRestart event.

◆ onStart()

void lintel::Process::onStart ( ) const

Trigger the onStart event.

◆ onStop()

void lintel::Process::onStop ( ) const

Trigger the onStop event.

◆ onTerminate()

void lintel::Process::onTerminate ( ) const

Trigger the onTerminate event.

◆ resetRestarts()

void lintel::Process::resetRestarts ( )

Reset the restart counter to zero.

◆ setActiveFromHour()

void lintel::Process::setActiveFromHour ( std::optional< int32_t >  activeFromHour)
Parameters
activeFromHouractive window start hour (0-23), disabled if nullopt

◆ setActiveToHour()

void lintel::Process::setActiveToHour ( std::optional< int32_t >  activeToHour)
Parameters
activeToHouractive window end hour (0-23), disabled if nullopt

◆ setCpuNotify()

void lintel::Process::setCpuNotify ( std::optional< double >  cpuNotify)
Parameters
cpuNotifyCPU usage percentage threshold that triggers a notify

◆ setMaxRestartRate()

void lintel::Process::setMaxRestartRate ( int  maxRestartRate)
Parameters
maxRestartRatemaximum restart count within the rate window (-1 = unlimited)

◆ setMemoryNotify()

void lintel::Process::setMemoryNotify ( std::optional< uint64_t >  memoryNotify)
Parameters
memoryNotifymemory usage threshold in bytes that triggers a notify

◆ setMinUptime()

void lintel::Process::setMinUptime ( std::chrono::milliseconds  minUptime)
Parameters
minUptimeminimum uptime in the restart window for a crash to count against the rate limit

◆ setRestartDelay()

void lintel::Process::setRestartDelay ( std::chrono::milliseconds  delay)
Parameters
delaybase backoff delay before the next auto-restart (0 = immediate)

◆ setRestartDelayMax()

void lintel::Process::setRestartDelayMax ( std::chrono::milliseconds  delayMax)
Parameters
delayMaxmaximum (capped) backoff delay (0 = no cap)

◆ setRestartInterval()

void lintel::Process::setRestartInterval ( std::chrono::milliseconds  restartInterval)
Parameters
restartIntervalperiodic restart interval (0 = disabled)

◆ setRestartWindow()

void lintel::Process::setRestartWindow ( std::chrono::milliseconds  restartWindow)
Parameters
restartWindowtime window over which the restart rate is evaluated

The documentation for this class was generated from the following file: