Last active
December 10, 2015 04:58
-
-
Save ovnicraft/4384681 to your computer and use it in GitHub Desktop.
OpenERP deployment with Gunicorn and Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deployment | |
La version 6.1 y 7.0 de openerp ahora soporta multihilo y depende de www.gunicorn.org que es el software que hace que use todos los cpus. | |
Dentro de la carpeta del server existe un archivo gunicorn.conf.py en donde se configura los parametros del sistema | |
Entonces ejecutamos la instruccion | |
gunicorn openerp:wsgi.core.application -c gunicorn.conf.py | |
desde le path del server y veremos como algunos hilos se ejecutan con el sistema automagicamente. | |
Probamos en el localhost:8069 y esta correcto. | |
Ahora queremos que el ERP corra en http://localhost sin el :8069 al final, esto para que cuando acceda a la ip del server le muestre el sistema: http://127.0.0.1 | |
Para esto necesitamos un web server como proxy. | |
Para esto tenemos el conocido http://httpd.apache.org/ y nuestra eleccion www.nginx.org (ambos se instalan facilmente con aptitude en ubuntu) | |
Nginx | |
Una vez instalado nginx debemos crear el archivo /etc/nginx/sites-availables/openerp y dentro ponemos la siguiente configuración: | |
server { | |
listen 80; | |
server_name openerp; | |
access_log /var/log/nginx/example.log; | |
location / { | |
proxy_pass http://127.0.0.1:8069; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
} | |
NOTA: para que el sistema sepa que va a correr en modo proxy en el archivo gunicorn de configuracion debe cambiarse import openerp por import.wsgi.proxied | |
Luego hacemos un softlink: | |
ln -s /etc/nginx/sites-available/openerp /etc/nginx/sites-enabled/openerp | |
reiniciamos nuestro nginx y listo http://127.0.0.1 tiene el erp. | |
Finalmente debemos poner el erp como servicio vamos a usar un supervisor de procesos para esto http://smarden.org/runit/faq.html#run | |
$sudo aptitude install runit | |
luego damos las siguiente instrucciones: | |
Ponemos el siguiente script | |
#!/bin/sh | |
GUNICORN=/usr/local/bin/gunicorn | |
ROOT=/home/openerp/openerp/server | |
PID=/var/run/gunicorn.pid | |
APP=openerp:wsgi.proxied.application | |
if [ -f $PID ]; then rm $PID; fi | |
cd $ROOT | |
exec $GUNICORN -c $ROOT/gunicorn.conf.py --pid=$PID $APP | |
en el archivo | |
/etc/sv/openerp/run | |
y lo hacemos ejecutable | |
chmod u+x /etc/sv/openerp/run | |
el directorio /etc/sv/openerp debe existir. | |
Entonces creamos un softlink | |
ln -s /etc/sv/openerp /etc/service/openerp | |
Listo tenemos openerp como servicio y con: | |
sv start|restart|stop openerp | |
podremos dar uso del mismo. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment