johnfk3
johnfk3

Reputation: 519

Uwsgi wont load app when run as service

I have setup a basic flask application in Centos 6, everything is contained in one file(app.py). I can run the file with uwsgi from the folder directory with the command uwsgi --ini myuwsgi.ini and everything works great. The contents of the ini file are:

[uwsgi]
http-socket    = :9090
plugin    = python
wsgi-file = /project/app.py
process   = 3
callable = app

However I want to set this up so everytime the server is shutdown or whatever that it will come up on its own. When I try to run the command service uwsgi start the logs show that no app was found. The ini file that the service uses is /etc/uwsgi.ini and I replaced it with my ini file.

The dump of the log is as follows if it helps:

*** Starting uWSGI 2.0.13.1 (64bit) on [Fri Sep  2 07:49:37 2016] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-17) on 02 August 2016 21:07:31
os: Linux-2.6.32-042stab113.21 #1 SMP Wed Mar 23 11:05:25 MSK 2016
nodename: uwsgiHost
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /
detected binary path: /usr/sbin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 14605
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :9090 fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 1315, cores: 1)
-- unavailable modifier requested: 0 --

If anyone could tell me why it cant find the app when i specified the location and callable in the ini?

Upvotes: 3

Views: 1899

Answers (1)

ettanany
ettanany

Reputation: 19806

Try the following config and let me know if it works for you:

[uwsgi]
callable = app
chdir = /path/to/your/project/
http-socket = :9090
plugins = python
processes = 4
virtualenv = /path/to/your/project/venv
wsgi-file = /path/to/your/project/app.py

You may also need to add uid and gid params.

Make sure that you have installed the package uwsgi-plugin-python:

apt-get install uwsgi-plugin-python

Upvotes: 3

Related Questions