[FIX] When using "--stop-after-init", set the return code correctly. A non zero return code reflect the number of databases that fail to load/update

bzr revid: chs@openerp.com-20130506103054-kb91drgkbj3z5799
This commit is contained in:
Christophe Simonis 2013-05-06 12:30:54 +02:00
parent 71530a3a9b
commit 2c4e370b76
1 changed files with 6 additions and 2 deletions

View File

@ -98,6 +98,8 @@ def preload_registry(dbname):
openerp.modules.registry.RegistryManager.new(dbname, update_module=update_module) openerp.modules.registry.RegistryManager.new(dbname, update_module=update_module)
except Exception: except Exception:
_logger.exception('Failed to initialize database `%s`.', dbname) _logger.exception('Failed to initialize database `%s`.', dbname)
return False
return True
def run_test_file(dbname, test_file): def run_test_file(dbname, test_file):
""" Preload a registry, possibly run a test file, and start the cron.""" """ Preload a registry, possibly run a test file, and start the cron."""
@ -261,12 +263,14 @@ def main(args):
else: else:
openerp.service.start_services() openerp.service.start_services()
rc = 0
if config['db_name']: if config['db_name']:
for dbname in config['db_name'].split(','): for dbname in config['db_name'].split(','):
preload_registry(dbname) if not preload_registry(dbname):
rc += 1
if config["stop_after_init"]: if config["stop_after_init"]:
sys.exit(0) sys.exit(rc)
_logger.info('OpenERP server is running, waiting for connections...') _logger.info('OpenERP server is running, waiting for connections...')
quit_on_signals() quit_on_signals()