Running Odoo as a systemd service is a professional solution that ensures the ERP system starts automatically after a server reboot and makes the process easy to manage. In this guide, you will learn how to properly configure Odoo as a systemd service on Linux systems.
Why run Odoo as a systemd service?
Systemd is a modern init and service management system in Linux distributions. Configuring Odoo as a systemd service brings a number of benefits:
- Automatic startup - Odoo starts automatically after a server reboot
- Easy management - Simple commands to start, stop and restart
- Process monitoring - Systemd monitors the application status and can restart it automatically in case of failure
- Resource isolation - Ability to set system resource limits
- Logging - Centralized log management through journald
Prerequisites
Before configuring the systemd service, make sure that:
- Odoo is installed on your system - if you haven't done so yet, check out how to install Odoo on Ubuntu
- PostgreSQL is configured - you can find more information in the article about configuring the PostgreSQL database for Odoo
- You have a prepared odoo.conf configuration file - see the comprehensive configuration guide
- You have root or sudo privileges on the system
Creating a system user for Odoo
For security reasons, it is recommended to run Odoo under a dedicated system user without root privileges:
sudo adduser --system --group odoo
This user will own the Odoo processes and the files related to the application. The home directory will be created automatically by the Odoo installer, or you can specify it manually during installation.
Configuring the systemd service file
To run Odoo as a systemd service, you need to create a service unit file. This is the main step of the configuration process.
Creating the service file
Create a new service file in the systemd directory:
sudo nano /etc/systemd/system/odoo.service
Contents of the odoo.service file
Paste the following configuration into the file you created:
[Unit]
Description=Odoo ERP System
Documentation=https://www.odoo.com
After=network.target postgresql.service
Requires=postgresql.service
[Service]
Type=simple
User=odoo
Group=odoo
SyslogIdentifier=odoo
PermissionsStartOnly=true
WorkingDirectory=/opt/odoo
ExecStart=/opt/odoo/odoo/odoo-bin --config=/etc/odoo/odoo.conf
StandardOutput=journal+console
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Explanation of the configuration sections
The [Unit] section contains basic information about the service:
Description- service description visible in the systemAfter- specifies that the service should start after the network and PostgreSQLRequires- defines a dependency on PostgreSQL
The [Service] section defines the startup parameters:
Type=simple- standard service type for applications running in the foregroundUserandGroup- specify the system userWorkingDirectory- working directory from which the service is runExecStart- command that starts Odoo (adjust the paths to your installation)Restart=on-failure- automatic restart in case of failureRestartSec=10- wait 10 seconds before restarting
The [Install] section defines the system target for automatic startup.
Adjusting paths in the service file
Make sure the paths in the service file are correct for your installation:
- WorkingDirectory - root directory of the Odoo installation (e.g.
/opt/odoo) - ExecStart - path to the Odoo executable (e.g.
/opt/odoo/odoo/odoo-binor/usr/bin/odoofor a package installation) - --config - path to the configuration file (e.g.
/etc/odoo/odoo.conf) - User/Group - name of the system user (usually
odoo)
Starting and managing the Odoo service
After creating the service file, perform the following steps:
Reloading the systemd configuration
sudo systemctl daemon-reload
Starting the Odoo service
sudo systemctl start odoo
Checking the service status
sudo systemctl status odoo
If everything is working correctly, you will see the status "active (running)" and information about the running process.
Enabling automatic startup
To make Odoo start automatically after a server reboot:
sudo systemctl enable odoo
Useful commands for managing the service
After configuring Odoo as a systemd service, you can use the following commands:
sudo systemctl stop odoo- stop the servicesudo systemctl restart odoo- restart the servicesudo systemctl reload odoo- reload the configuration without stopping (requires proper signal handling in Odoo)sudo systemctl disable odoo- disable automatic startupsudo journalctl -u odoo -f- follow the logs in real timesudo journalctl -u odoo --since today- today's logs
Troubleshooting
The service does not start
If the service does not start, check the logs:
sudo journalctl -xe -u odoo
The most common causes of problems:
- Incorrect paths in the service file (especially ExecStart and WorkingDirectory)
- Errors in the odoo.conf configuration file
- Missing permissions to directories (addons, log, data_dir)
- PostgreSQL is not running or is misconfigured
- The port is already in use by another process
- Missing required Python dependencies
Verifying permissions
Make sure the odoo user has the appropriate permissions:
sudo chown -R odoo:odoo /opt/odoo
sudo chown -R odoo:odoo /var/log/odoo
sudo chown odoo:odoo /etc/odoo/odoo.conf
sudo chmod 640 /etc/odoo/odoo.conf
Advanced configuration options
Resource limits
You can add resource limits in the [Service] section:
LimitNOFILE=524288
LimitNPROC=8192
MemoryLimit=2G
CPUQuota=200%
The LimitNOFILE parameter specifies the maximum number of open files - for Odoo 17+ the recommended value is 524288. CPUQuota allows you to limit CPU usage (200% = 2 cores).
Environment variables
If you need to set environment variables:
Environment="PATH=/opt/odoo/venv/bin:/usr/local/bin:/usr/bin:/bin"
Environment="LC_ALL=pl_PL.UTF-8"
Environment="LANG=pl_PL.UTF-8"
Multi-instance configuration
To run multiple Odoo instances, create separate service files with different names (e.g. odoo-prod.service, odoo-test.service). For each instance you must:
- Create a separate configuration file with a unique port (
xmlrpc_port) and longpolling_port - Specify a separate data_dir directory for each instance
- Optionally use separate PostgreSQL databases
- Configure different paths for logs
Example for a second instance:
ExecStart=/opt/odoo/odoo/odoo-bin --config=/etc/odoo/odoo-test.conf
FAQ - Frequently Asked Questions
How do I change the port the Odoo service runs on?
The Odoo port is configured in the odoo.conf file, not in the systemd service file. Edit the configuration file and change the xmlrpc_port parameter, then restart the service with the command sudo systemctl restart odoo. You can find a detailed guide in the article on how to change the Odoo port.
Can I run Odoo as a service on Windows?
Systemd is specific to Linux systems. Windows uses a different mechanism - Windows Services. During Odoo installation on Windows the installer automatically configures a system service that you can manage through the Windows Services panel.
What should I do if the Odoo service does not start automatically after an update?
After updating Odoo to a newer version, check whether the paths in the /etc/systemd/system/odoo.service file are still correct. Sometimes an update can change the location of executable files. Run sudo systemctl daemon-reload to reload the configuration, then check the logs with the command sudo journalctl -u odoo -n 50. You can read more about the update process in the article on how to upgrade Odoo to a newer version.
Summary
Running Odoo as a systemd service is a professional and reliable solution for production environments. With this configuration, you gain full control over the Odoo process, automatic startup after a server reboot, and easy management of logs and monitoring. Remember to check the logs regularly and keep your system updated to ensure optimal performance and security.
Need help with your Odoo configuration?
If you need professional help configuring Odoo as a systemd service or with other aspects of your ERP implementation, the KK Innovations team is at your disposal. We offer comprehensive technical support, implementations, training and customization of Odoo to the specific needs of your company. Contact us to find out how we can help optimize your Odoo environment!