8.odoo入门——初探odoo后台启动过程(二)
来源:互联网 发布:宁波软件行业协会 编辑:程序博客网 时间:2024/05/22 03:28
接着之前探索odoo后台启动的过程,上次讲到是进入了server.py ,那么就查看server.py的源代码,其结构大致如下:
def .....#若干函数class Server(Command): """Start the odoo server (default command)""" def run(self, args): main(args)
也就是command.py中的最后几行代码
if command in commands: o = commands[command]() o.run(args)
将命令行参数换入server中的参数args,调用Server类的run方法,看到在server.py中定义的main(args)函数:
def main(args): check_root_user() #如果是linux系统并且是root用户,弹出警告 odoo.tools.config.parse_config(args) #位于odoo10/odoo/tools/config.py的 parse_config 函数#这个函数的作用是 Parse the configuration file (if any) and the command-line arguments. check_postgres_user()#参考: http://www.2cto.com/database/201508/430456.html#这个函数的作用是如果从odoo/tools/config.py中处理脚本配置文件得到的数据中检测到用户是‘postgres’(类似于Linux的root),#就会拒绝登陆,并且弹出错误信息 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) 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)#————又调用了odor/service/server.py下的run函数啦 sys.exit(rc)
其中report_configuration()源码如下:
def report_configuration(): """ Log the server version and some configuration values. This function assumes the configuration has been initialized. """ config = odoo.tools.config _logger.info("Odoo version %s", __version__) if os.path.isfile(config.rcfile): _logger.info("Using configuration file at " + config.rcfile) _logger.info('addons paths: %s', odoo.modules.module.ad_paths) host = config['db_host'] or os.environ.get('PGHOST', 'default') port = config['db_port'] or os.environ.get('PGPORT', 'default') user = config['db_user'] or os.environ.get('PGUSER', 'default') _logger.info('database: %s@%s:%s', user, host, port)
可以考到,利用logger输出了几条信息,其实这就是我们在正常启动odoo服务端后台看到的几条交互信息,比如说我的其中几条信息如下:
其中setup_pid_file()源码如下:
def setup_pid_file(): """ Create a file with the process id written in it. This function assumes the configuration has been initialized. """ #print "what the fuck!!!!!!” #这是我自己写的测试语句 config = odoo.tools.config if not odoo.evented and config['pidfile']: #print "nothing!” #我自己写的测试语句 pid = os.getpid() with open(config['pidfile'], 'w') as fd: ##print "what the fuck" , config['pidfile'] ############ fd.write(str(pid)) atexit.register(rm_pid_file, pid)
创建一个含pid的文件,但是我的服务端启动时,what the fuck的输出位置是不一定的(也就是说可能是多线程的),nothing!不会输出,说明我们没有进入if语句——也对,我们的配置文件中并没有关于pidfile的选项
下一步,该探寻odor/service/server.py下的run函数啦
阅读全文
0 0
- 8.odoo入门——初探odoo后台启动过程(二)
- 16.odoo入门——初探后台启动过程(三)
- 17.odoo入门——初探后台启动过程(四)
- 7.odoo入门——初探odoo后台启动过程(一)
- 19.odoo入门——odoo的session
- 8.odoo入门——jinja2入门(一)
- 10.11.12.odoo入门——杂记
- 20.odoo入门——杂记
- 21.odoo入门——杂记
- 22.odoo入门——工作杂记
- 23.odoo入门——工作杂记
- 24.odoo入门——工作杂记
- Odoo
- 18.odoo入门——odoo权限控制(一)模型(数据表)级别权限控制
- 4.odoo入门——培训签到课程项目(二),后端逻辑
- 6.odoo入门——培训签到课程项目(三)
- 13.odoo入门——杂记之git
- 26.odoo入门——工作杂记之many2one
- BZOJ1002轮状病毒
- 关于shell-----1
- hpuoj【1069】两两相加 【数学】
- Elasticsearch之高亮进阶-高性能高亮器, 让Elasticsearch飞一会儿
- 1086: [SCOI2005]王室联邦
- 8.odoo入门——初探odoo后台启动过程(二)
- 【优先队列】
- Android屏幕适配
- 数据类型转换之 QByteArray 与 char*
- PHP代码审计CSRF 跨站请求伪造
- 多线程端口扫描
- 准确率(Accuracy), 精确率(Precision), 召回率(Recall)和F1-Measure
- Java-9-简单的OKHttp使用
- poj1661 Help Jimmy-dp动态规划 (M)