It is time to move my Python Eve Api to a production environment. There are several ways to do this, and the most common are:
- Error Logging
- Automatic update
- Multiple processes (if possible)
The best solution I found is to have a nginx server as an external server. With python python running on uWSGI middleware .
Problem: I have a custom __main__one that is not being called by uwsgi.
Does anyone have this configuration or other suggestion? As soon as this works, I will share the current configuration.
thank.
Solution (update):
Following the suggestion below, I moved the Eve () method to init .py and ran the application using sperate wsgi.py.
Folder structure :
webservice / init.py web service / modules / ... settings.py wsgi.py
Where init.py contains
app = Eve(auth=globalauth.TokenAuth)
Bootstrap(app)
app.config['X_DOMAINS'] = '*'
...
and wsgi.py contains
from webservice import app
if __name__ == "__main__":
app.run()
wsgi.ini
[uwsgi]
chdir=/var/www/api/prod
module=wsgi:app
socket=/tmp/api.sock
processes=1
master=True
pidfile=/tmp/api.v1.pid
max-requests=5000
daemonize=/var/www/api/logs/prod.api.log
logto=/var/www/api/logs/uwsgi.log
nginx.conf
location = /v1 { rewrite ^ /v1/; }
location /v1 { try_files $uri @apiWSGIv1; }
location @apiWSGIv1 {
include uwsgi_params;
uwsgi_modifier1 30;
uwsgi_pass unix:/tmp/digdisapi.sock;
}
start command:
uwsgi --ini uwsgi.ini
source
share