mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot: catch exceptions during main loop
* If an excpetion occurs during the main loop, the builder crashes. With this commit, the main_loop is in a try/catch. Also: * remove unused imports * move the first log after the Odoo import because Odoo changes the process timezone to UTC
This commit is contained in:
parent
501142c561
commit
f4ef66e029
@ -2,9 +2,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import threading
|
import threading
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
@ -29,21 +27,28 @@ class RunbotClient():
|
|||||||
host = self.env['runbot.host']._get_current()
|
host = self.env['runbot.host']._get_current()
|
||||||
count = 0
|
count = 0
|
||||||
while True:
|
while True:
|
||||||
host.last_start_loop = fields.Datetime.now()
|
try:
|
||||||
count = count % 60
|
host.last_start_loop = fields.Datetime.now()
|
||||||
if count == 0:
|
count = count % 60
|
||||||
logging.info('Host %s running with %s slots on pid %s%s', host.name, host.get_nb_worker(), os.getpid(), ' (assigned only)' if host.assigned_only else '')
|
if count == 0:
|
||||||
self.env['runbot.repo']._source_cleanup()
|
logging.info('Host %s running with %s slots on pid %s%s', host.name, host.get_nb_worker(), os.getpid(), ' (assigned only)' if host.assigned_only else '')
|
||||||
self.env['runbot.build']._local_cleanup()
|
self.env['runbot.repo']._source_cleanup()
|
||||||
self.env['runbot.repo']._docker_cleanup()
|
self.env['runbot.build']._local_cleanup()
|
||||||
host.set_psql_conn_count()
|
self.env['runbot.repo']._docker_cleanup()
|
||||||
_logger.info('Scheduling...')
|
host.set_psql_conn_count()
|
||||||
count += 1
|
_logger.info('Scheduling...')
|
||||||
sleep_time = self.env['runbot.repo']._scheduler_loop_turn(host)
|
count += 1
|
||||||
host.last_end_loop = fields.Datetime.now()
|
sleep_time = self.env['runbot.repo']._scheduler_loop_turn(host)
|
||||||
self.env.cr.commit()
|
host.last_end_loop = fields.Datetime.now()
|
||||||
self.env.reset()
|
self.env.cr.commit()
|
||||||
self.sleep(sleep_time)
|
self.env.reset()
|
||||||
|
self.sleep(sleep_time)
|
||||||
|
except Exception as e:
|
||||||
|
_logger.exception('Builder main loop failed with: %s', e)
|
||||||
|
self.env.cr.rollback()
|
||||||
|
self.env.reset()
|
||||||
|
self.sleep(10)
|
||||||
|
|
||||||
if self.ask_interrupt.is_set():
|
if self.ask_interrupt.is_set():
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -80,11 +85,10 @@ def run():
|
|||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
logging.getLogger().addHandler(handler)
|
logging.getLogger().addHandler(handler)
|
||||||
|
|
||||||
_logger.info("Staring sheduler on database %s", args.database)
|
|
||||||
|
|
||||||
# configure odoo
|
# configure odoo
|
||||||
sys.path.append(args.odoo_path)
|
sys.path.append(args.odoo_path)
|
||||||
import odoo
|
import odoo
|
||||||
|
_logger.info("Starting scheduler on database %s", args.database)
|
||||||
odoo.tools.config['db_host'] = args.db_host
|
odoo.tools.config['db_host'] = args.db_host
|
||||||
odoo.tools.config['db_port'] = args.db_port
|
odoo.tools.config['db_port'] = args.db_port
|
||||||
odoo.tools.config['db_user'] = args.db_user
|
odoo.tools.config['db_user'] = args.db_user
|
||||||
@ -102,6 +106,7 @@ def run():
|
|||||||
# run main loop
|
# run main loop
|
||||||
runbot_client.main_loop()
|
runbot_client.main_loop()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run()
|
run()
|
||||||
_logger.info("Stopping gracefully")
|
_logger.info("Stopping gracefully")
|
||||||
|
Loading…
Reference in New Issue
Block a user