首页 > uwsgi --xml命令执行卡住了

uwsgi --xml命令执行卡住了

我这么执行的:

sudo uwsgi --xml /etc/uwsgi/apps-available/example.com.xml

到了set cpu affinity for worker 2 to 1输出这里就卡在那里了。
qq群里有人说这是因为我没有将进程放到后台,所以我又执行了

sudo uwsgi --daemonize /var/log/uwsgi.log

然后重新uwsgi --xml,仍然卡在同一个地方。
这应该怎么解决?

xml文件如下:

<uwsgi>
    <plugin>python</plugin>
    <socket>/run/uwsgi/app/example.com/example.com.socket</socket>
    <pythonpath>/srv/www/example.com/application/</pythonpath>
    <app mountpoint="/">
        <script>wsgi_configuration_module</script>
    </app>
    <master/>
    <processes>4</processes>
    <harakiri>60</harakiri>
    <pidfile>project-master.pid</pidfile>
    <reload-mercy>8</reload-mercy>
    <cpu-affinity>1</cpu-affinity>
    <stats>/tmp/stats.socket</stats>
    <max-requests>2000</max-requests>
    <limit-as>512</limit-as>
    <reload-on-as>256</reload-on-as>
    <reload-on-rss>192</reload-on-rss>
    <no-orphans/>
    <vacuum/>
</uwsgi>

采用ini配置方式,比较简洁。

[uwsgi]
# set the socket

socket = 127.0.0.1:8000
# the project directory
chdir = /your_project_path/project
# maximum number of worker processes

# wsgi file
# just like the django wsgi.py file path, if your swgi file in the django
# settings file location. 
module = project.wsgi

processes = 4
# run each worker in prethreaded mode with the specified number of threads
threads = 2

# vacuum all of the generated file/sockets
vacuum = true 
# enable the stats server on the specified address
stats = 127.0.0.1:9191
# reload if rss memory is higher than specified megabytes ,256 means 256MB
reload-on-rss = 256 
# reload if address space is higher than specified megabytes
reload-on-as = 256

# set the maximum time (in seconds) we wait for 
# workers and other processes to die during reload/shutdown
reload-mercy=10

pidfile=project.pid

# reload workers after the specified amount of managed requests
max-requests = 6000

正常输出:

writing pidfile to project.pid
detected binary path: /Library/Frameworks/Python.framework/Versions/2.7/bin/uwsgi
chdir() to /Users/project/project
your processes number limit is 709
your memory page size is 4096 bytes
detected max file descriptor number: 256
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /Users/nooper/project/project.sock fd 3
Python version: 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)  [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
Python main interpreter initialized at 0x7fa808d01210
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415280 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x7fa808d01210 pid: 9873 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 9873)
spawned uWSGI worker 1 (pid: 9875, cores: 2)
spawned uWSGI worker 2 (pid: 9876, cores: 2)
spawned uWSGI worker 3 (pid: 9877, cores: 2)
spawned uWSGI worker 4 (pid: 9878, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 15 ***

如果采用 cpu-affinity 设置就需要根据CPU多核进行考虑,现在大部分CPU是多核,比如i7, 2核心4个线程,如果设置为1会导致,线程和进程会在一个核心上运行,必然没有利用CPU的多核技术。http://blog.csdn.net/normalnotebook/article/details/771581,
http://linux.chinaunix.net/techdoc/system/2008/02/04/978083.shtml

【热门文章】
【热门文章】