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 add-ons path and the log file. If 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 log filtering, refer to Chapter 8, Debugging, where you will find the Producing server logs to help debug methods recipe. 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 add-ons 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 request handling is performed in separate threads, which are as follows:

  • Requests can be handled in parallel by 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:

Parameter

Suggested value

Description

limit_memory_hard

4294967296

This is the maximum amount of RAM a worker will be able to allocate. We recommend using 4 GB, as some processes launched by Odoo can allocate large amounts of RAM.

limit_memory_soft

671088640

If a worker ends up consuming more than this limit (640 MB in our setting), it will be terminated after it finishes processing the current request.

limit_request

8192

A worker will be terminated after having processed this many requests.

limit_time_cpu

120

This is the maximum amount of CPU time allowed to process a request.

limit_time_real

300

This is the maximum amount of wall-clock time allowed to process a request.

Step 12 configures the internal Odoo web server to only listen on the local interface. This means that 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 Configuring a reverse proxy and SSL recipe later in this chapter.

If you are not sure about the number of workers for your server setup, use the following formula to calculate number of workers for your system:

No. of workers = (No. of CPU * 2) + 1 

Here, one worker can handle approximately six concurrent users. 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset