【odoo】【知识杂谈】单一实例多库模式下定时任务的问题分析 (2)

查找上级为,server.py中的main函数,至此所有思路都清晰了,看源码

def main(args): check_root_user() odoo.tools.config.parse_config(args) check_postgres_user() report_configuration() config = odoo.tools.config # the default limit for CSV fields in the module is 128KiB, which is not # quite sufficient to import images to store in attachment. 500MiB is a # bit overkill, but better safe than sorry I guess csv.field_size_limit(500 * 1024 * 1024) preload = [] if config['db_name']: preload = config['db_name'].split(',') for db_name in preload: try: odoo.service.db._create_empty_database(db_name) config['init']['base'] = True except ProgrammingError as err: if err.pgcode == errorcodes.INSUFFICIENT_PRIVILEGE: # We use an INFO loglevel on purpose in order to avoid # reporting unnecessary warnings on build environment # using restricted database access. _logger.info("Could not determine if database %s exists, " "skipping auto-creation: %s", db_name, err) else: raise err except odoo.service.db.DatabaseExists: pass if config["translate_out"]: export_translation() sys.exit(0) if config["translate_in"]: import_translation() sys.exit(0) # This needs to be done now to ensure the use of the multiprocessing # signaling mecanism for registries loaded with -d if config['workers']: odoo.multi_process = True stop = config["stop_after_init"] setup_pid_file() rc = odoo.service.server.start(preload=preload, stop=stop) sys.exit(rc)

在上面,我们preload为配置文件中的db_name的值,那么正向梳理回去就是
a) odoo在启动的时候加载odoo.conf配置文件,并读取db_name的值
b) 加载完成后将通过db_name的值初始化数据库对象;
c) 并在完成cron线程初始化后循环调用库对象,执行相关定时任务。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwzfzg.html