forked from caruccio/openshift-openerp-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathwsgi.py
79 lines (62 loc) · 2.83 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
import os
virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
pass
#
# IMPORTANT: Put any additional includes below this line. If placed above this
# line, it's possible required libraries won't be in your searchable path
#
import sys
ODOO_ROOT_DIR = os.path.join(os.environ.get('OPENSHIFT_DATA_DIR', '.'), 'odoo')
if ODOO_ROOT_DIR not in sys.path:
sys.path.append(ODOO_ROOT_DIR)
os.environ['XDG_DATA_HOME'] = os.path.join(os.environ.get('OPENSHIFT_DATA_DIR', '.'),'.local/share')
os.environ['XDG_CACHE_HOME'] = os.path.join(os.environ.get('OPENSHIFT_DATA_DIR', '.'),'.cache')
os.environ['XDG_CONFIG_HOME'] = os.path.join(os.environ.get('OPENSHIFT_DATA_DIR', '.'),'.config')
import openerp
#----------------------------------------------------------
# Common
#----------------------------------------------------------
openerp.multi_process = True # Nah!
# Equivalent of --load command-line option
openerp.conf.server_wide_modules = ['web']
conf = openerp.tools.config
# Path to the ODOO Addons repository (comma-separated for
# multiple locations)
conf['addons_path'] = ','.join([os.path.join(ODOO_ROOT_DIR,'openerp' ,'addons'),os.path.join(ODOO_ROOT_DIR, 'addons'),os.path.join(os.environ.get('OPENSHIFT_REPO_DIR', '.'), 'addons')])
#conf['addons_path'] = os.path.join(os.environ.get('OPENSHIFT_REPO_DIR', '.'), 'addons')
# Optional database config if not using local socket
conf['admin_passwd'] = os.environ.get('ODOO_ADMIN_PASS','superadm0n')
conf['db_host'] = os.environ['OPENSHIFT_POSTGRESQL_DB_HOST']
conf['db_port'] = int(os.environ['OPENSHIFT_POSTGRESQL_DB_PORT'])
conf['db_user'] = os.environ['OPENSHIFT_POSTGRESQL_DB_USERNAME']
conf['db_name'] = os.environ['OPENSHIFT_APP_NAME']
conf['db_password'] = os.environ['OPENSHIFT_POSTGRESQL_DB_PASSWORD']
conf['logfile'] = os.path.join(os.environ.get('OPENSHIFT_LOG_DIR', '.') , 'odoo.log')
#----------------------------------------------------------
# Generic WSGI handlers application
#----------------------------------------------------------
application = openerp.service.wsgi_server.application
openerp.service.server.load_server_wide_modules()
#----------------------------------------------------------
# Gunicorn
#----------------------------------------------------------
# Standard ODOO XML-RPC port is 8069
#bind = '127.0.0.1:8069'
#pidfile = ODOO_ROOT_DIR+'.gunicorn.pid'
#workers = 4
#timeout = 240
#max_requests = 2000
#
# Below for testing only
#
#if __name__ == '__main__':
# from wsgiref.simple_server import make_server
# httpd = make_server('localhost', 8051, application)
# # Wait for a single request, serve it and quit.
# httpd.handle_request()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: