@ -15,6 +15,17 @@ class Process():
- 3 _STOP_SAFE_MANUAL
- 4 _STARTED
- 5 _STARTED_MANUAL
. . code - block : : python
lProcess = Orchestrator . Managers . Process ( inAgentHostNameStr = " PCNAME " , inAgentUserNameStr = " USER " ,
inProcessNameWOExeStr = " notepad " , inStartCMDStr = " notepad " , inStopSafeTimeoutSecFloat = 3 )
# Async way to run job
lProcess . ScheduleStatusCheckEverySeconds ( inIntervalSecondsInt = 5 )
Orchestrator . OrchestratorScheduleGet ( ) . every ( 5 ) . seconds . do ( Orchestrator . OrchestratorThreadStart ,
lProcess . StartCheck )
# OR (sync mode)
Orchestrator . OrchestratorScheduleGet ( ) . every ( 5 ) . seconds . do ( lProcess . StartCheck )
"""
mAgentHostNameStr = None
@ -77,6 +88,16 @@ class Process():
self . StatusChangeLog ( )
return self . mStatusStr
def StartCheck ( self ) - > str :
"""
Start program if auto stopped ( 0 _STOPPED ) .
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
if self . mStatusStr == " 0_STOPPED " :
self . Start ( inIsManualBool = False )
return self . mStatusStr
def StopSafe ( self , inIsManualBool = True ) - > str :
"""
Manual / Auto stop safe . Stop safe is the operation which send signal to process to terminate own work ( send term signal to process ) . Managers . Process wait for the mStopSafeTimeoutSecFloat seconds . After that , if process is not terminated - self will StopForce it .
@ -115,6 +136,16 @@ class Process():
self . StatusChangeLog ( )
return self . mStatusStr
def StopSafeCheck ( self ) - > str :
"""
Stop safe program if auto started ( 4 _STARTED ) .
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
if self . mStatusStr == " 4_STARTED " :
self . StopSafe ( inIsManualBool = False )
return self . mStatusStr
def StopForce ( self , inIsManualBool = True ) - > str :
"""
Manual / Auto stop force . Force stop don ' t wait process termination - it just terminate process now.
@ -139,6 +170,16 @@ class Process():
self . StatusChangeLog ( )
return self . mStatusStr
def StopForceCheck ( self ) - > str :
"""
Stop force program if auto started ( 4 _STARTED ) .
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
if self . mStatusStr == " 4_STARTED " :
self . StopForce ( inIsManualBool = False )
return self . mStatusStr
def RestartSafe ( self , inIsManualBool = True ) :
"""
Manual / Auto restart safe . Restart safe is the operation which send signal to process to terminate own work ( send term signal to process ) . Then it run process . Managers . Process wait for the mStopSafeTimeoutSecFloat seconds . After that , if process is not terminated - self will StopForce it .
@ -228,6 +269,15 @@ class Process():
self . StopSafe ( inIsManualBool = False )
return self . mStatusStr
def ScheduleStatusCheckEverySeconds ( self , inIntervalSecondsInt = 120 ) :
"""
Run status check every interval in second you specify .
: param inIntervalSecondsInt : Interval in seconds . Default is 120
: return : None
"""
# Check job in threaded way
__Orchestrator__ . OrchestratorScheduleGet ( ) . every ( inIntervalSecondsInt ) . seconds . do ( __Orchestrator__ . OrchestratorThreadStart , self . StatusCheck )
def ProcessGet ( inAgentHostNameStr : str , inAgentUserNameStr : str , inProcessNameWOExeStr : str ) - > Process :
"""