0
Good afternoon, you guys!
I researched a lot on the internet and did not succeed, I have the following problem to solve:
I have 3 Python services installed on Windows(example1.py / example2.py / example3.py) running normally, but the service only collects information once a month, but runs every 24 hours, on a specific day, 2 and 3 are daily and run every 3 hours.
I want to create another service that monitors the 3 created, that start at the exact date or once a day and after completion of the routine close completely, starting only the next day or at a specific date.
My 3 services start as follows:
class TestService(win32serviceutil.ServiceFramework):
_svc_name_ = 'exemplo1'
_svc_display_name_ = 'exemplo1'
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
socket.setdefaulttimeout(60)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
self.main()
def main(self):
def retorna_data_00(dt):
midnight = datetime.time(0)
return datetime.datetime.combine(dt.date(), midnight)
def data_modificacao(FileName):
t = os.path.getmtime(FileName)
return datetime.date.fromtimestamp(t)
And it closes as follows:
if __name__ == '__main__':
if len(sys.argv) == 1:
servicemanager.Initialize()
servicemanager.PrepareToHostSingle(TestService)
servicemanager.StartServiceCtrlDispatcher()
else:
win32serviceutil.HandleCommandLine(TestService)
Among these functions is the entire script that collects information from the bank, transforms it into a spreadsheet and sends it by email.
When Voce says he wants a service that monitors others, I imagine it’s something that shows if everyone is running and can point to a possible correct failure?
– Jose Paulo
In fact also, I need the routine to make the points mentioned above and perform the start in the services to and stop when completed.
– Daymon Rebac