Skip to main content

How to create odoo as a service

For the odoo installation steps please follow steps in my previous post.

Assume i have saved my code in following path
/home/pranav/my_code/odoo




1)Create “odoo-server.conf” file and copy and paste below content.


[options] ; This is the password that allows database operations: admin_passwd = password db_host = localhost db_port = 5432 db_user = pranav db_password = postgres db_name = <db_name> dbfilter = <db_name> addons_path = /home/pranav/my_code/odoo/odoo/addons,/home/pranav/my_code/odoo/addons,/home/pranav/my_code/custom_module logfile = /var/log/odoo/odoo-server.log xmlrpc = True xmlrpc_port=8088




2)Paste the file in "/etc" folder and change its permission and access mode


chown <user_name>: -R /home/pranav/my_code/odoo
chown <user_name>: /etc/odoo-server.conf
chmod 640 /etc/odoo-server.conf

3)Create file "odoo-server" inside "/etc/init.d" folder with below content

#!/bin/sh
### BEGIN INIT INFO
# Provides: odoo-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Business Applications
# Description: ODOO Business Applications.
### END INIT INFO
PATH=/bin:/sbin:/usr/bin
DAEMON=/home/pranav/my_code/odoo/odoo-bin (It may change according to your downloaded bundle)
NAME=odoo-server
DESC=odoo-server


# Specify the user name (Default: openerp).
USER=<user_name>


# Specify an alternate config file (Default: /etc/odoo-server.conf).
CONFIGFILE="/etc/odoo-server.conf"


# pidfile
PIDFILE=/var/run/$NAME.pid


# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"
[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0
checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1
}


case "${1}" in
start)
echo -n "Starting ${DESC}: "
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}
echo "${NAME}."
;;
stop)
echo -n "Stopping ${DESC}: "
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
echo "${NAME}."
;;


restart|force-reload)
echo -n "Restarting ${DESC}: "
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}
echo "${NAME}."
;;
*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;


esac
exit 0


4)Change above file permission and access mode

chmod 755 /etc/init.d/odoo-server
chown <user_name>: /etc/init.d/odoo-server


5)Create log file inside "/var/log/odoo" folder

chowm <user_name>:/var/log/odoo
touch /var/log/odoo/odoo-server.log
chmod 777 /var/log/odoo/odoo-server.log

6)Start the service

/etc/init.d/odoo-service start

To view log data
tail -f /var/log/odoo/odoo-server.log

7)Add as service

sudo systemctl daemon-reload
sudo systemctl enable odoo-server.service
sudo systemctl start odoo-server.service

Comments

Popular posts from this blog

How to create multiple services of Odoo(above version 10) on windows

In this post, I will explain how we can create multiple Odoo services in a Windows Server. Step 1 First, you need to get the executable file from the Odoo link mentioned below Or open the already existing executable file.   https://www.odoo.com/page/download   If you are running the executable file for the second time uncheck Postgres installation since it is already done in the first install. Keep a note of your installation path. Step 2 Go to the below path where "Odoo 12.0 Test" is the directory your new installation files belong to: C:\Program Files (x86)\Odoo 12.0 Test\nssm\win64\ Open the command prompt  and type the below command: nssm install odoo-server-TEST   A User Interface similar to the image below will popup, you have to fill the three empty fields with values I mentioned below Step 3 Path : C:\Program Files (x86)\Odoo 12.0 Test\Python\python.exe Startup directory : C:\Program Files (x86)\Odoo 12.0 Test\server Arguments : "C:\Program Files (x86)\Odoo 1...

How to setup apache web server in linux?

APACHE Apache server is the most commonly used web hosting service,  mainly the websites developed in php , python etc. We can host your website to a local network so that people in same network can access. In Linux Apache use split structure for configuring files, in which it will be defining hostname, port ,ssl etc each in different configuration files. Similarly file sharing can be made possible using apache server. Now we shall try to create a sample website hosted in apache server. Step 1: Install  apache2 in to the system $sudo apt-get update //update the repository for latest version of softwares $sudo apt-get install apache2 Step2: create a directory in '/var/www/' folder which is the default folder for storing site datas. (Var folder is known as variable folder since it is used to store growing folder like log files,backups etc) sudo mkdir -p /var/www/sample.com/public_html Step 3: Grant user permission for the folder $sudo chown -R $U...

HOW TO VERIFY YOUR BLOG

Since it is not possible to upload a page in blog we need alternative method to verify your blog, using meta tag. For that go to google web master tool https://www.google.com/webmasters/tools/ and do the following steps. 1,Click the "Add a property" button on the Webmaster Tools Home page. 2.Enter your blog's URL (for example, programmersbasics.blogspot.com) and click the "add" button to go to the Manage verification page. 3.Select the "Meta tag" verification method and copy the meta tag provided.Just copy aand paste it some where for future use.This tag is permanat for one site. 4,Login to your bloggers account and select the blog. 5,Select the template tag in left, it is just above settings. 6,Click 'Edit HTML' button below Live on blog section. 7,Add the meta tag just below <head> and save. 8,Then goto webmasters page and click verify. Now you are verified.You can now access webmaster features.