Python gunicorn怎么安装和使用
本篇内容主要讲解“Python gunicorn怎么安装和使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python gunicorn怎么安装和使用”吧!
Gunicorn “Green Unicorn”是用于UNIX的Python WSGI HTTP服务器。从Ruby的Unicorn项目移植而来的fork-worker模型。Gunicorn服务器与各种web框架广泛兼容,实现简单,服务器资源少,速度相当快。
特征
原生支持WSGI、Django和Paster
自动工作进程管理
简单的Python配置
多个工作机配置
用于扩展性的各种服务器hooks
兼容Python 3.x>=3.5
安装
pipinstallgunicorn
运行
$gunicorn[OPTIONS][WSGI_APP]语法WSGI_APP:{module_import}:{app_variable}
示例
#等价于'fromhelloimportapp'$gunicorn-w4'hello:app'#等价于'fromhelloimportcreate_app;create_app()'$gunicorn-w4'hello:create_app()'
配置文件 gunicorn.conf.py
-h,--helpshowthishelpmessageandexit-v,--versionshowprogram'sversionnumberandexit-cCONFIG,--configCONFIGTheGunicornconfigfile.[./gunicorn.conf.py]-bADDRESS,--bindADDRESSThesockettobind.[['127.0.0.1:8000']]--backlogINTThemaximumnumberofpendingconnections.[2048]-wINT,--workersINTThenumberofworkerprocessesforhandlingrequests.[1]-kSTRING,--worker-classSTRINGThetypeofworkerstouse.[sync]--threadsINTThenumberofworkerthreadsforhandlingrequests.[1]--worker-connectionsINTThemaximumnumberofsimultaneousclients.[1000]--max-requestsINTThemaximumnumberofrequestsaworkerwillprocessbeforerestarting.[0]--max-requests-jitterINTThemaximumjittertoaddtothe*max_requests*setting.[0]-tINT,--timeoutINTWorkerssilentformorethanthismanysecondsarekilledandrestarted.[30]--graceful-timeoutINTTimeoutforgracefulworkersrestart.[30]--keep-aliveINTThenumberofsecondstowaitforrequestsonaKeep-Aliveconnection.[2]--limit-request-lineINTThemaximumsizeofHTTPrequestlineinbytes.[4094]--limit-request-fieldsINTLimitthenumberofHTTPheadersfieldsinarequest.[100]--limit-request-field_sizeINTLimittheallowedsizeofanHTTPrequestheaderfield.[8190]--reloadRestartworkerswhencodechanges.[False]--reload-engineSTRINGTheimplementationthatshouldbeusedtopower:ref:`reload`.[auto]--reload-extra-fileFILESExtends:ref:`reload`optiontoalsowatchandreloadonadditionalfiles[[]]--spewInstallatracefunctionthatspewseverylineexecutedbytheserver.[False]--check-configChecktheconfigurationandexit.Theexitstatusis0ifthe[False]--print-configPrinttheconfigurationsettingsasfullyresolved.Implies:ref:`check-config`.[False]--preloadLoadapplicationcodebeforetheworkerprocessesareforked.[False]--no-sendfileDisablestheuseof``sendfile()``.[None]--reuse-portSetthe``SO_REUSEPORT``flagonthelisteningsocket.[False]--chdirCHDIRChangedirectorytospecifieddirectorybeforeloadingapps.[/Users/hina/Desktop/domain-admin-test]-D,--daemonDaemonizetheGunicornprocess.[False]-eENV,--envENVSetenvironmentvariablesintheexecutionenvironment.[[]]-pFILE,--pidFILEAfilenametouseforthePIDfile.[None]--worker-tmp-dirDIRAdirectorytousefortheworkerheartbeattemporaryfile.[None]-uUSER,--userUSERSwitchworkerprocessestorunasthisuser.[501]-gGROUP,--groupGROUPSwitchworkerprocesstorunasthisgroup.[20]-mINT,--umaskINTAbitmaskforthefilemodeonfileswrittenbyGunicorn.[0]--initgroupsIftrue,settheworkerprocess'sgroupaccesslistwithallofthe[False]--forwarded-allow-ipsSTRINGFront-end'sIPsfromwhichallowedtohandlesetsecureheaders.[127.0.0.1]--access-logfileFILETheAccesslogfiletowriteto.[None]--disable-redirect-access-to-syslogDisableredirectaccesslogstosyslog.[False]--access-logformatSTRINGTheaccesslogformat.[%(h)s%(l)s%(u)s%(t)s"%(r)s"%(s)s%(b)s"%(f)s""%(a)s"]--error-logfileFILE,--log-fileFILETheErrorlogfiletowriteto.[-]--log-levelLEVELThegranularityofErrorlogoutputs.[info]--capture-outputRedirectstdout/stderrtospecifiedfilein:ref:`errorlog`.[False]--logger-classSTRINGTheloggeryouwanttousetologeventsinGunicorn.[gunicorn.glogging.Logger]--log-configFILEThelogconfigfiletouse.[None]--log-syslog-toSYSLOG_ADDRAddresstosendsyslogmessages.[unix:///var/run/syslog]--log-syslogSend*Gunicorn*logstosyslog.[False]--log-syslog-prefixSYSLOG_PREFIXMakesGunicornusetheparameterasprogram-nameinthesyslogentries.[None]--log-syslog-facilitySYSLOG_FACILITYSyslogfacilityname[user]-R,--enable-stdio-inheritanceEnablestdioinheritance.[False]--statsd-hostSTATSD_ADDR``host:port``ofthestatsdservertologto.[None]--dogstatsd-tagsDOGSTATSD_TAGSA ma-delimitedlistofdatadogstatsd(dogstatsd)tagstoappendto[]--statsd-prefixSTATSD_PREFIXPrefixtousewhenemittingstatsdmetrics(atrailing``.``isadded,[]-nSTRING,--nameSTRINGAbasetousewithsetproctitleforprocessnaming.[None]--pythonpathSTRINGA ma-separatedlistofdirectoriestoaddtothePythonpath.[None]--pasteSTRING,--pasterSTRINGLoadaPasteDeployconfigfile.Theargumentmaycontaina``#``[None]--proxy-protocolEnabledetectPROXYprotocol(PROXYmode).[False]--proxy-allow-fromPROXY_ALLOW_IPSFront-end'sIPsfromwhichallowedacceptproxyrequestsmaseparate).[127.0.0.1]--keyfileFILESSLkeyfile[None]--certfileFILESSLcertificatefile[None]--ssl-versionSSL_VERSIONSSLversiontouse.[_SSLMethod.PROTOCOL_TLS]--cert-reqsCERT_REQSWhetherclientcertificateisrequired(seestdlibsslmodule's)[VerifyMode.CERT_NONE]--ca-certsFILECAcertificatesfile[None]--suppress-ragged-eofsSuppressraggedEOFs(seestdlibsslmodule's)[True]--do-handshake-on-connectWhethertoperformSSLhandshakeonsocketconnect(seestdlibsslmodule's)[False]--ciphersCIPHERSSSLCiphersuitetouse,intheformatofanOpenSSLcipherlist.[None]--paste-globalCONFSetaPasteDeployglobalconfigvariablein``key=value``form.[[]]--strip-header-spacesStripspacespresentbetweentheheadernameandthethe``:``.[False]
到此,相信大家对“Python gunicorn怎么安装和使用”有了更深的了解,不妨来实际操作一番吧!这里是主机评测网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
上一篇:GS Admin限流功能怎么使用
下一篇:node.js怎么爬取知乎图片
winlogins.exe是什么文件?winlogins.exe是不是病毒
winsock2.6.exe是什么文件?winsock2.6.exe是不是病毒
WinDefendor.dll是什么文件?WinDefendor.dll是不是病毒
系统目录是什么文件?系统目录是不是病毒
wholove.exe是什么文件?wholove.exe是不是病毒
winn.ini是什么文件?winn.ini是不是病毒
w6oou.dll是什么文件?w6oou.dll是不是病毒
winduxzawb.exe是什么文件?winduxzawb.exe是不是病毒
wuammgr32.exe是什么文件?wuammgr32.exe是不是病毒
windiws.exe是什么文件?windiws.exe是不是病毒