[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-1":3},{"id":4,"title":5,"title_en":6,"abstract":7,"abstract_en":8,"content":9,"content_en":10,"category":11,"banner_id":12,"banner_path":13,"tags":14,"is_recommend":17,"prev_article":18,"next_article":21,"created_at":25},1,"uwsgi.ini 常用配置参数详解","uwsgi.ini Detailed explanation of common configuration parameters","# uwsgi.ini 常用配置参数详解\n\n```shell\nmaster = true \n\n#启动主进程，来管理其他进程，其它的uwsgi进程都是这个master进程的子进程，如果kill这个mas","# uwsgi.ini Detailed explanation of common configuration parameters\n\n```shell\nmaster = true \n\n#启动主进程 to manage other processes, other uwsgi processes are children of this master process, if you kill this mas","# uwsgi.ini 常用配置参数详解\n\n```shell\nmaster = true \n\n#启动主进程，来管理其他进程，其它的uwsgi进程都是这个master进程的子进程，如果kill这个master进程，相当于重启所有的uwsgi进程。\n\nchdir = \u002Fweb\u002Fwww\u002Fmysite \n#在app加载前切换到当前目录， 指定运行目录\n\nmodule = mysite.wsgi \n# 加载一个WSGI模块,这里加载mysite\u002Fwsgi.py这个模块\n\npy-autoreload=1  \n#监控python模块mtime来触发重载 (只在开发时使用)\n\nlazy-apps=true  \n#在每个worker而不是master中加载应用\n\nsocket = \u002Ftest\u002Fmyapp.sock \n#指定socket文件，也可以指定为127.0.0.1:9000，这样就会监听到网络套接字\n\nprocesses = 2 #启动2个工作进程，生成指定数目的worker\u002F进程\n\nworkers = 4 #启动4个工人\n\nthreads=4 #启动4个线程\n\nenable-threads=True #开启多线程模式\n\nbuffer-size = 32768 #设置用于uwsgi包解析的内部缓存区大小为64k。默认是4k。\n\ndaemonize = \u002Fvar\u002Flog\u002Fmyapp_uwsgi.log \n# 使进程在后台运行，并将日志打到指定的日志文件或者udp服务器\n\nlog-maxsize = 5000000 #设置最大日志文件大小\n\ndisable-logging = true #禁用请求日志记录\n\nvacuum = true #当服务器退出的时候自动删除unix socket文件和pid文件。\n\nlisten = 120 #设置socket的监听队列大小（默认：100）\n\npidfile = \u002Fvar\u002Frun\u002Fuwsgi.pid #指定pid文件\n\nenable-threads = true \n#允许用内嵌的语言启动线程。这将允许你在app程序中产生一个子线程\n\nreload-mercy = 8 \n#设置在平滑的重启（直到接收到的请求处理完才重启）一个工作子进程中，等待这个工作结束的最长秒数。这个配置会使在平滑地重启工作子进程中，如果工作进程结束时间超过了8秒就会被强行结束（忽略之前已经接收到的请求而直接结束）\n\nmax-requests = 5000 \n#为每个工作进程设置请求数的上限。当一个工作进程处理的请求数达到这个值，那么该工作进程就会被回收重用（重启）。你可以使用这个选项来默默地对抗内存泄漏\n\nlimit-as = 256 \n#通过使用POSIX\u002FUNIX的setrlimit()函数来限制每个uWSGI进程的虚拟内存使用数。这个配置会限制uWSGI的进程占用虚拟内存不超过256M。如果虚拟内存已经达到256M，并继续申请虚拟内存则会使程序报内存错误，本次的http请求将返回500错误（当产生内存错误时，可能是内存使用数设置不足）\n\nharakiri = 60 \n#一个请求花费的时间超过了这个harakiri超时时间，那么这个请求都会被丢弃，并且当前处理这个请求的工作进程会被回收再利用（即重启）\n```","#Detailed explanation of common configuration parameters uwsgi.ini\n\n```shell\nmaster = true \n\n#Start the main process to manage other processes. Other uwsgi processes are child processes of the master process. If the master process is killed, it is equivalent to restarting all uwsgi processes.\n\nchdir = \u002Fweb\u002Fwww\u002Fmysite \n#Switch to the current directory before the app loads and specify the running directory\n\nmodule = mysite.wsgi \n#Load a WSGI module, here load the mysite\u002Fwsgi.py module\n\npy-autoreload=1  \n#Monitor python module mtime to trigger overloading (only used during development)\n\nlazy-apps=true  \n#Load apps in every worker instead of master\n\nsocket = \u002Ftest\u002Fmyapp.sock \n#Specify the socket file, or you can specify it as 127.0.0.1:9000, so that the network socket will be monitored\n\nprocesses = 2 #Start 2 worker processes and generate the specified number of workers\u002Fprocesses\n\nworkers = 4 #Start 4 workers\n\nthreads=4 #Start 4 threads\n\nenable-threads=True #Enable multithreaded mode\n\nbuffer-size = 32768 #Set the internal buffer size used for uwsgi package parsing to 64k. The default is 4k.\n\ndaemonize = \u002Fvar\u002Flog\u002Fmyapp_uwsgi.log \n#Make the process run in the background and log to the specified log file or udp server\n\nlog-maxsize = 5000000 #Set the maximum log file size\n\ndisable-logging = true #Disable request logging\n\nvacuum = true #Automatically deletes unix socket files and pid files when the server quits.\n\nlisten = 120 #Set the listening queue size of the socket (default: 100)\n\npidfile = \u002Fvar\u002Frun\u002Fuwsgi.pid #Specify a pid file\n\nenable-threads = true \n#Allow starting threads in embedded languages. This will allow you to generate a subthread in the app\n\nreload-mercy = 8 \n#Set the maximum number of seconds to wait for the end of a work subprocess during a smooth restart (not restarting until the received request is processed). This configuration will cause the smooth restart of the working sub-process, if the working process ends more than 8 seconds, it will be forcibly terminated (ignoring previous requests and ending directly)\n\nmax-requests = 5000 \n#Set a maximum number of requests for each worker process. When the number of requests processed by a worker process reaches this value, the worker process will be recycled (restarted). You can use this option to silently fight memory leaks\n\nlimit-as = 256 \n#Limit the amount of virtual memory used by each uWSGI process by using the POSIX\u002FUNIX setrlimit() function. This configuration limits uWSGI processes to no more than 256M of virtual memory. If the virtual memory has reached 256M and continues to apply for virtual memory, the program will report a memory error. This http request will return a 500 error (when a memory error occurs, it may be that the memory usage is not set enough)\n\nharakiri = 60 \n#If a request takes longer than the harakiri timeout, the request will be dropped and the working process currently processing the request will be recycled (i.e. restarted)\n```","部署",0,"https:\u002F\u002Fblog4-1316398321.cos.ap-nanjing.myqcloud.com\u002Fblog5\u002F20250712142354__卡冈图雅黑洞.png",[15,16],"Python","Linux",false,{"id":12,"title":19,"title_en":20},"已经是第一篇了","This is already the first article",{"id":22,"title":23,"title_en":24},2,"Django指定IP访问（限制IP访问）","Django specifies IP access (restricts IP access)","2025-07-21T05:00:10+08:00"]