A
A
Anton Manevant2014-03-24 14:38:25
Python
Anton Manevant, 2014-03-24 14:38:25

How to start uwsgi server without console interception?

There is a bunch of django + uwsgi + nginx.
I usually start the server from the console - uwsgi and a set of arguments

uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket=666

After that uwsgi intercepts the console.
2 questions.
1. How to run uwsgi without console interception? (In fact, if the ssh connection is broken, the server stops)
2. Is it possible to make uwsgi a development server? In order for it to be automatically reloaded when the code changes and conveniently launched via python manage.py runserver ? (Like the default development server).
Thank you very much in advance.
PS I'm a noob.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Anton Kuzmichev, 2014-03-24
@Manevant

Only recently I tried to deploy a small test project (I myself have only two months of experience in Python & Django). In the end, everything worked out, I launched uwsgi in the so-called "Emperor mode". Used virtual environment. Installed uwsgi (pip install) in the system, by the way, and not in venv.
The file /etc/init/uwsgi.conf is created with the content:

# Emperor uWSGI script

description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]

exec uwsgi --master --die-on-term --emperor /etc/uwsgi/vassals

The /etc/uwsgi/vassals folder contains project configs (one for each project), with something like this:
# mysite_uwsgi.ini file
[uwsgi]

## process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 3
# the socket (use the full path to be safe
socket          = /home/user/virtualenvs/mysite/uwsgi.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true
# user, group
uid=mysiteuser
gid=mysitegroup

## Django-related settings
# the virtualenv (full path)
home            = /home/user/virtualenvs/mysite/
# the base directory (full path)
chdir           = /home/user/virtualenvs/mysite/www
# Django's wsgi file
module          = mysite.wsgi

Now uswgi is managed as a service: sudo service uwsgi (start|status|stop|restart etc.) and no busy consoles.
As for auto-reload when content changes: I haven't tried it yet, but I think this is it

U
un1t, 2014-03-24
@un1t

Why run it like that?
Create config
/etc/nginx/sites-available/example.conf
Here is an example

[uwsgi]
plugins=python27
socket=/var/run/example.sock
virtualenv=/home/webapps/example.com/example/python/
module=wsgi
callable=app
pythonpath=/home/ilya/webapps/example.com/example
chdir=/home/ilya/webapps/example.com/example

Then we restart uwsgi and that's it.
sudo service uwsgi restart

V
v_prom, 2014-03-24
@v_prom

for development, you can use screen. at least when you break ssh will not stop.

K
Kir ---, 2014-11-14
@SowingSadness

It is enough to specify --pidfile

uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket=666 --pidfile /run/uwsgi.pid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question