English 中文(简体)
uwsgi + django via Nginx - uwsgi settings/spawn?
原标题:

I am leaning towards uwsgi+nginx for my Django app, can anyone share the best method for starting up my uwsgi processes? Does anyone have experience tuning uwsgi?

最佳回答

Launchd on OSX

Upstart/init on the unices.

uwsgi also has its own process manager, so you can just run that as well.

Tuning:

Check the mailing list, for advice on your particular requirements. Uwsgi is amazing, it is a complete deploy solution.

Nginx above 0.8.40 will build the uwsgi bindings by default, Build nginx, build uwsgi and you are golden.

问题回答

these are the functions i use in my fabfile.py file (check out python fabric if you haven t already):

def start_uwsgi():
    with cd(env.server.uwsgi):
        if(exists( server.pid )):
            stop_uwsgi()
            run( sleep 1 )
        run( source venv/bin/activate;uwsgi --ini uwsgi.ini; ))

def stop_uwsgi():
    with cd(env.server.uwsgi):
        if(exists( server.pid )):
            run( source venv/bin/activate;uwsgi --stop server.pid; ))

In my uwsgi.ini file i specify:

[uwsgi]
socket = :{{your_port}}
master = true
vhost = true
no-site = true
processes = 1
enable-threads = true
pidfile = server.pid
daemonize = server.log
auto-procname = true
procname-prefix = servername_

for me the main gotyas were:

  • use the daemonise option if you want to keep the uwsgi server going after you close your terminal/ssh session
  • use vhost to run multiple sites under the same uwsgi instance, which is great if your bottleneck is memory, like mine is with the otherwise fantastic webfaction host
  • pidfile tracks the current instance, enabling you to call uwsgi --stop pidfile, uwsgi --start pidfile
  • procname and procname-prefix/append give a nice name to your process so you can easily single it out using ps -u username | grep some_string

I will go with supervisord for managing the starting, stoping process.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签