Score:0

Cant start wsgi through Nginx

er flag

At first: When i started nginx i see errors in log:

unix:/root/project/flask_paramiko.sock failed (13: Permission denied) while connecting to upstream

uwsgi.ini:

[uwsgi]
#chdir  = /root/project
module = wsgi:app

master = true
processes = 5

socket = flask_paramiko.sock
chmod-socket = 666
vacuum = true

die-on-term = true

wsgi.py

from flask_paramiko import app

if __name__ == "__main__":
    app.run()

uwsgi --socket /root/project/flask_paramiko.sock --wsgi-file wsgi.py:

unable to find "application" callable in file wsgi.py
unable to load app 0 (mountpoint='') (callable not found or import error)

/usr/bin/uwsgi --ini /root/project/uwsgi.ini works fine without any errors.

I don't mind where is an error.

anx avatar
fr flag
anx
`/root/` does not sound like a path you would typically want accessible to anyone other than an internal system user called `root`. Also, how exactly are you starting uwsgi (a systemD unit? a sysV init script? - the chdir parameter might actually be useful if your init daemon does not pass the directory)
Explorethetruth avatar
er flag
Moved to different folder. Starting uwsgi via systemd unit.
Score:0
fr flag
anx

You are using two different options, one specifies just the file the other the module

--module=wsgi:app works fine without any errors

--wsgi-file=wsgi.py unable to find "application" callable

(there is not much difference between --option=value on cmdline and option value in the ini)

The literal application is just the name uwsgi defaults to looking for if you only pass the file name. If you application is called app instead, well then say so on the command line or in the config.

Explorethetruth avatar
er flag
Thanks. Solved this problem. Can i ask additional question? My flask app serving a many "routes", do i need to create all of them in nginx.conf? or nginx have an easy way to serve it?
anx avatar
fr flag
anx
First ask yourself: *Do I need Nginx to treat different routes differently?* In any case, thoroughly read the documentation of your framework (sounds like *flask*) on what other considerations are important during deployment, there is more to this than just routes.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.