mac uwsgi多进程
配置文件
[uwsgi]
http = 127.0.0.1:1088
chdir = /Users/libaotong/Documents/python/tfgame_spider/
wsgi-file = run.py
callable = app
processes = 4
master = true
logto = logs/online_api.log
threads = 2
daemonize = logs/uwsgi.log
virtualenv=/Users/libaotong/Documents/python/tfgame_spider/venv
stats = 127.0.0.1:9191
如果配合nginx使用,则配置为:socket = 127.0.0.1:1088
mac运行错误
运行时报错
objc[61000]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
原因:macOS的High Sierra以上的操作系统对多进程的限制
解决办法
运行前,导入系统变量
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
一劳永逸的办法:
sudo echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> ~/.bash_profile && source ~/.bash_profile
BTW
# 杀掉所有uwsgi
ps -ef|grep uwsgi|grep -v '.svn'|awk '{print $2}'|xargs kill -9
# 启动uwsgi
uwsgi --ini config/uwsgi.ini
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!