使用systemctl重启和更新Odoo服务

4

Odoo服务使用systemctl start odoo启动。我使用的是Centos系统。当我想要更新我的*.py代码时,我通常会按照以下步骤进行:

1. systemctl stop odoo
Then I update my module and database by useing this:
2. ./odoo.py -c openerp-server.conf -u <my_module_name> -d <database_name>
3. stop service by ctrl + c
4. systemctl start odoo

但是更新更改的方式真的很冗长和不舒服。

有没有更短的方法以更短的方式执行相同的操作?

2个回答

3

使用 Odoo 服务

您可以进行以下更改:

  1. 停止服务器:systemctl stop odoo
  2. 启动服务器:systemctl start odoo。这里会更新 .py 文件。
  3. 如果您还需要更新 xml 或某些翻译,可以在 Odoo 界面上的模块描述表单中按下 更新 按钮。

注意:有一些模块可以重新加载特定的 xml 视图。如果您感兴趣,我可以查看并找到相应的模块。

不使用 Odoo 服务

如果您在本地开发,无需使用 systemctl。只需直接运行 odoo.py,即可立即查看更改内容:

./odoo.py -c openerp-server.conf -u <my_module_name> -d <database_name>

自动重新加载Python文件

当Python文件发生更改时,有另一种选项可以重新加载它们。请查看其他答案

Normally if you change your python code means, you need to restart the server in order to apply the new changes.

--auto-reload parameter is enabled means, you don't need to restart the server. It enables auto-reloading of python files and xml files without having to restart the server. It required pyinotify. It is a Python module for monitoring filesystems changes.

Just add --auto-reload in your configuration file. By default the value will be "false". You don't need to pass any extra arguments. --auto-reload is enough. If everything setup and works properly you will get

openerp.service.server: Watching addons folder /opt/odoo/v8.0/addons
openerp.service.server: AutoReload watcher running in the server log. Don't forget to install pyinotify package.
在Odoo 10中,只需添加--dev=reload参数即可。
--dev=DEV_MODE      Enable developer mode. Param: List of options
                    separated by comma. Options : all,
                    [pudb|wdb|ipdb|pdb], reload, qweb, werkzeug, xml

我更改了my_module_a和my_module_b。在openerp-server.conf中,我没有任何数据库过滤器,并且我正在使用3个数据库。因此,当我运行systemctl start odoo时,在所有3个数据库中.py文件都会被更新吗?希望你能理解我的问题。 - fueggit
据我所知,在服务重新启动后(systemctl start odoo),.py文件会根据odoo-service.conf文件中过滤的数据库自动更新。 - fueggit
是的,如果您更新了Python文件,则同一实例的所有数据库都将被更新。如果您想要更新XML文件,则需要在您想要更新的每个数据库中手动执行此操作。 - ChesuCR

0
Failed to stop odoo.service: Access denied. See system logs and 'systemctl status odoo.service' for details.

起初,我遇到了这个错误。然后尝试使用su命令,得到了这个结果。

Failed to stop odoo.service: Unit odoo.service not loaded.

我的关注点是如何通过识别完美的文件,在新模块安装后重新启动Odoo服务。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接