Registro y salida chistosa

master
ifiguero 2022-01-21 01:36:23 -03:00
parent a086bcc616
commit b8da20c194
2 changed files with 8 additions and 6 deletions

View File

@ -4,19 +4,19 @@ import daemon
import time
import signal
import asyncio
import sys
if not os.environ.get('HEARTBEAT'):
hb = 60 * 15 # 15 minutos
else:
hb = int(os.environ.get('HEARTBEAT'))
shouldIrun = True
def main():
async def main_loop():
await log.info('Demonio iniciado')
doki = int(time.time()) + hb
while True:
while shouldIrun:
if await pre_process():
await enviaCorreos()
await asyncio.sleep(10)
@ -31,7 +31,7 @@ def main():
def programCleanup(_signo, _stack_frame):
log.info('Recibida señal de salida!')
sys.exit(0)
shouldIrun = False
run()

View File

@ -4,7 +4,6 @@ import daemon
import time
import signal
import asyncio
import sys
if not os.environ.get('HEARTBEAT'):
@ -12,6 +11,9 @@ if not os.environ.get('HEARTBEAT'):
else:
hb = int(os.environ.get('HEARTBEAT'))
shouldIrun = True
def main():
mayordomo = create_async_smtp_server()
@ -19,7 +21,7 @@ def main():
async def main_loop():
await log.info('Demonio iniciado')
doki=int(time.time()) + hb
while True:
while shouldIrun:
await asyncio.sleep(1)
i = int(time.time())
if i >= doki:
@ -34,7 +36,7 @@ def main():
def programCleanup(_signo, _stack_frame):
log.info('Recibida la señal de salida')
mayordomo.stop()
sys.exit(0)
shouldIrun = False
run()