使用 systemctl 重新启动和更新 Odoo 服务

Odoo service restart and update using systemctl

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

但更新更改的方式确实很长且不舒服。

有没有更短的方法可以用更短的方式完成相同的操作?

带有服务的 Odoo

您可以像这样进行更改:

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

注意:有一些模块可以重新加载特定的 xml 视图。如果你对它感兴趣,我可以看看我是否找到了。

没有服务的 Odoo

如果您在本地计算机上进行开发,则不需要使用 systemctl。只需 运行 Odoo 直接使用 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
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 服务post新模块安装。