For a production instance, it is very important that the Odoo server gets started when the computer reboots. On current Linux systems, there are different ways of achieving this, depending on the distribution and the server setup; either it is an init script, or a systemd
configuration. This recipe shows how to do both.
We assume that you followed the first two recipes to install and configure your Odoo instance. Especially the deployed source of Odoo, which is at /home/odoo/odoo-prod/project/src/odoo/
, and the configuration file of the instance, which is at /home/odoo/odoo-prod/project/production.conf
. The scripts also makes use of the start-odoo
script created in step 9 of the Install Odoo for production recipe.
You will first need to find out which initialization system is running on your system. For this, run the following:
$ dpkg -l systemd
If the last line of output starts with ii systemd
, then systemd
is available on your system. Otherwise, you are probably running sysvinit
(on a system running an old Debian variant) or upstart (on an Ubuntu-based system).
Now that you know which version of the initialization system you are running, you can choose how to configure Odoo.
To configure systemd to start Odoo, you need to perform the following steps:
/lib/systemd/system/odoo.service
, with the following contents:[Unit] Description=Odoo 9.0 After=postgresql.service [Service] Type=simple User=odoo Group=odoo ExecStart=/home/odoo/odoo-prod/project/bin/start-odoo [Install] WantedBy=multi-user.target
# systemctl enable odoo.service
# service odoo start
# service odoo stop
To configure
sysvinit
or upstart
to start Odoo, you need to perform the following steps:
init
file provided by Odoo to /etc/init.d
:# cp src/odoo/debian/init /etc/init.d/odoo # chmod +x /etc/init.d/odoo
DAEMON=/home/odoo/odoo-prod/project/bin/start-odoo
_start
function as follows:function _start() { start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON }
sysvinit
or upstart:# update-rc.d odoo defaults
# /etc/init.d/odoo start
# /etc/init.d/odoo stop
The three configurations, systemd
, sysvinit
, and upstart
, use some configuration files or scripts to know which programs must run when the server boots. The configurations provided in the recipe will need small adaptations to match the paths of your instance.
18.216.124.145