Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 39 ยท Deployment and Customisation

Configuration and Deployment

Configure and deploy Odoo: the odoo.conf file, command-line options, addons_path, workers and limits sizing, a systemd service and a production checklist with runnable calculators.

On a laptop, Odoo starts with one command and a database. In production it must start by itself, survive restarts, use all CPUs, stay secure and be easy to upgrade. Most of that is configuration, and nearly all of the configuration lives in one file, odoo.conf.

No Odoo server runs on this site, so commands and files are read-only. The stand-ins parse a configuration with the standard library and compute worker settings from machine size.

Starting Odoo

Terminal
python3 odoo-bin -c /etc/odoo/odoo.conf                     # normal start
python3 odoo-bin -c odoo.conf -d mydb -i library            # install module "library"
python3 odoo-bin -c odoo.conf -d mydb -u library            # upgrade it (reloads XML and updates tables)
python3 odoo-bin -c odoo.conf --dev=all                     # development helpers
python3 odoo-bin shell -c odoo.conf -d mydb                 # interactive ORM shell
python3 odoo-bin scaffold library ./custom_addons           # create a module skeleton

-i installs, -u updates, and -d names the database. Updating is how XML changes (views, security, data) reach an existing database, while Python changes just need a restart. --dev=all turns on auto-reload of Python and XML and shows tracebacks in the browser, which is for development only.

A typical odoo.conf

INI
[options]
; security
admin_passwd = CHANGE-ME-LONG-RANDOM
list_db = False
dbfilter = ^mycompany$

; database
db_host = 127.0.0.1
db_port = 5432
db_user = odoo
db_password = DB-SECRET

; code
addons_path = /opt/odoo/odoo/addons,/opt/odoo/addons,/opt/odoo/custom_addons

; web
http_port = 8069
gevent_port = 8072
proxy_mode = True

; performance
workers = 5
max_cron_threads = 1
limit_memory_soft = 2147483648
limit_memory_hard = 2684354560
limit_time_cpu = 60
limit_time_real = 120

; logging
logfile = /var/log/odoo/odoo.log
log_level = info

What each part does:

  • admin_passwd is the master password for the database manager screen (create, drop, back up databases). Set a strong value, and consider list_db = False so the screen and database list are hidden. Odoo can store a hashed value.
  • dbfilter restricts which databases a hostname can open, a regular expression that may use %h (host) or %d (first subdomain part).
  • addons_path is an ordered, comma-separated list of folders searched for modules. Put your own folder last or first deliberately: the first match for a module name wins.
  • proxy_mode must be on behind nginx or any reverse proxy so Odoo trusts the forwarded host and protocol headers.
  • gevent_port (called longpolling_port in old versions) serves the live updates connections such as chat; the proxy routes /websocket there when running with workers.

Workers and limits

With workers = 0 Odoo runs in a threaded mode, fine for development only. In production set workers greater than 0 so it uses a pre-forking multi-process server. A common starting formula is:

  • workers about (CPU cores x 2) + 1, but at most as many as memory allows.
  • Each worker uses roughly 150 to 300 MB at rest and up to the soft limit under load.
  • limit_memory_soft makes a worker restart after finishing its current request; limit_memory_hard kills it.
  • limit_time_cpu and limit_time_real stop runaway requests.
  • A cron worker (max_cron_threads) is separate from request workers.
flowchart LR
    U["Browser"] --> N["nginx :443"]
    N -->|"/"| W["Odoo workers :8069"]
    N -->|"/websocket"| G["Gevent worker :8072"]
    W --> P[("PostgreSQL")]
    G --> P
    C["Cron thread"] --> P

A reverse proxy terminates HTTPS, sends normal traffic to the workers and live connections to the gevent port.

Reading and sizing

This first stand-in parses an odoo.conf with configparser and flags risky settings, the kind of check you could put in a deployment pipeline.

Python Lint an odoo.conf

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second stand-in turns machine size into starting values. It is a rule of thumb, not an official formula; measure and adjust.

Python Estimate workers from CPU and RAM

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Running as a service

On Linux, systemd keeps Odoo running and starts it at boot:

INI
[Unit]
Description=Odoo
After=network.target postgresql.service

[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/opt/odoo/venv/bin/python /opt/odoo/odoo-bin -c /etc/odoo/odoo.conf
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable it with systemctl enable --now odoo, and read logs with journalctl -u odoo or the logfile. Run Odoo as a dedicated, unprivileged user, in a Python virtual environment that matches the version's supported Python release.

Production checklist

  1. Strong admin_passwd, list_db = False, and a dbfilter for single-database hosts.
  2. PostgreSQL on a private interface with its own user (not a superuser), tuned shared_buffers and regular vacuum.
  3. HTTPS with a reverse proxy, proxy_mode = True and the websocket route.
  4. workers above 0, memory and time limits, and the wkhtmltopdf binary installed for reports (QWeb PDF Reports).
  5. An outgoing mail server configured, or emails will pile up in the queue (Automated Actions, Cron Jobs and Email).
  6. Backups that you have actually restored once (Backups and Upgrades).
  7. Log rotation and monitoring of disk, RAM and the ir_cron queue.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command-line flag updates an installed module so XML changes load into the database?

    -u (update) reloads the module's data files and updates its tables; -i installs it the first time.
  2. 2. Why is proxy_mode = True needed behind nginx?

    Without it, links and redirects can use the wrong host or http instead of https.
  3. 3. What is workers = 0 suitable for?

    Zero workers means threaded mode, which cannot enforce per-request limits and doesn't use several CPUs well.
  4. 4. What does the admin_passwd option protect?

    It guards creating, duplicating, dropping and backing up databases from the manager screen.

Summary

  • odoo.conf holds database, paths, ports, security and performance settings; flags -i, -u and -d install, update and choose a database.
  • Set a strong admin_passwd, disable list_db and use dbfilter.
  • Use workers and memory/time limits in production, and proxy_mode behind a reverse proxy.
  • Run Odoo as a service under an unprivileged user and follow a checklist.

Next: Docker, nginx and HTTPS