How it works...

Most of the parameters shown in this recipe are explained in the Manage Odoo server instances recipe in Chapter 1, Installing the Odoo Development Environment.

In steps 3, 4, and 5, we change the addons path and the log file. In case you are developing in an environment with the same layout as the production environment, this is required because Odoo expects absolute paths in the configuration file.

Step 6 enables log rotation. This will cause Odoo to configure the logging module to archive the server logs on a daily basis, and to keep the old logs for 30 days. This is useful on production servers to avoid logs eventually consuming all the available disk space.

Step 7 configures the logging level. The proposed setting is very conservative and will only log messages with at least the WARNING level, except for werkzeug (CRITICAL) and odoo.service.server (INFO). For more information on the log filtering, refer to Chapter 8, Debugging and Automated Testing, where you will find the recipe, Producing server logs to help debug methods. Feel free to tune this to your taste.

Step 8 configures the database settings. This will work if you are running the PostgreSQL database server locally and have set it up as explained in the previous recipe. If you're running PostgreSQL on a different server, you will need to replace the False values with the appropriate connection settings for your database instance.

Step 9 restricts the database available to the instance by configuring a database filter. We also disable the database listing, which is not strictly necessary given that the regular expression we set in dbfilter can only match one single database. It is still a good thing to do though, in order to avoid displaying the list of databases to anyone, and to avoid users connecting to the wrong database.

Step 10 sets a nontrivial master password for the instance. The master password is used for database management through the user interface, and a few community addons also use it for extra security before performing actions that can lead to data loss. You really need to set this to a nontrivial value. We propose using the pwgen utility to generate a random password, but any other method is also valid.

Step 11 configures Odoo to work with workers. In this mode, Odoo will create a number of worker processes (in this example, 4) to handle HTTP requests. This has several advantages over the default configuration in which the request handling is performed in separate threads, which are given as follows:

  • Requests can be handled in parallel, making better use of multiple cores or CPUs on the server (Python threads are penalized by the existence of the Global Interpreter Locks (GIL) in the Python interpreter).
  • It is possible to terminate one of the workers depending on resource consumption. The following table gives the various resource limits that can be configured:

Step 12 configures the internal Odoo web server to only listen on the local interface. This means the instance will not be reachable from other servers. This enables us to configure a reverse proxy on the same server to access the server and to force encrypted connections. Take a look at the Configure a reverse proxy and SSL recipe later in this chapter.