{"id":1959,"date":"2018-11-04T23:16:35","date_gmt":"2018-11-04T14:16:35","guid":{"rendered":"https:\/\/proxy.goincop1.workers.dev:443\/http\/www.python.ambitious-engineer.com\/?p=1959"},"modified":"2018-12-02T16:19:58","modified_gmt":"2018-12-02T07:19:58","slug":"uwsgi%e5%85%a5%e9%96%80","status":"publish","type":"post","link":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/archives\/1959","title":{"rendered":"uWSGI\u5165\u9580"},"content":{"rendered":"<p>Python\u3067Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u305f\u5f8c\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067\u7a3c\u50cd\u3055\u305b\u308b\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002\uff08\u958b\u767a\u6642\u306f\u7d44\u307f\u8fbc\u307f\u306e\u30b5\u30fc\u30d0\u30fc\u3067\u5341\u5206\u3067\u3059\u304c\u3001\u672c\u756a\u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\uff09\u3053\u3053\u3067\u306fPython\u3067\u3088\u304f\u4f7f\u308f\u308c\u308buWSGI\u3068\u3044\u3046\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>uWSGI\u3068\u306f<\/h2>\n<h3>WSGI\u3068\u306f<\/h3>\n<p>uWSGI\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3059\u308b\u524d\u306b\u3001WSGI\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3057\u307e\u3057\u3087\u3046\u3002WSGI\uff08Web Server Gateway Interface\uff09 \u3068\u306f\u3001Python\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068Web\u30b5\u30fc\u30d0\u30fc\u9593\u3068\u306e\u3084\u308a\u53d6\u308a\u306e\u898f\u7d04\u3001\u30d7\u30ed\u30c8\u30b3\u30fc\u30eb\u306e\u3053\u3068\u3067PEP333\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.org\/dev\/peps\/pep-3333\/\">https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.org\/dev\/peps\/pep-3333\/<\/a><\/p>\n<p>Python\u306e\u5927\u62b5\u306eWeb\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306f\u3053\u306eWSGI\u3068\u3044\u3046\u898f\u7d04\u306b\u5247\u3063\u3066\u3044\u307e\u3059\u3002\u6709\u540d\u3069\u3053\u308d\u3068\u3057\u3066\u4ee5\u4e0b\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>Django<\/li>\n<li>Flask<\/li>\n<li>Bottle<\/li>\n<\/ul>\n<h3>uWSGI\u3068\u306f<\/h3>\n<p>uWSGI\u3068\u306fPython\u3067Web\u30b5\u30fc\u30d3\u30b9\u3092\u52d5\u304b\u3059\u305f\u3081\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0(\u4ee5\u964d\u3001AP\u30b5\u30fc\u30d0\u30fc\u3068\u7565\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002)\u306e\u4e00\u7a2e\u3067\u3059\u3002\u4e0a\u8a18\u306eWSGI\u306b\u5247\u3063\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u52d5\u4f5c\u3055\u305b\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u3092WSGI\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b3\u30f3\u30c6\u30ca\u3084WSGI\u30b5\u30fc\u30d0\u306a\u3069\u3068\u547c\u3073\u307e\u3059\u3002uWSGI\u306f\u3001\u3053\u306eWSGI\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b3\u30f3\u30c6\u30ca\u306e\u4e00\u7a2e\u3067\u3059\u3002\u3064\u307e\u308a\u3001WSGI\u306b\u6e96\u62e0\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u3042\u308c\u3070\u3001\u4e0a\u3067\u6319\u3052\u305fDjango\u3084Flask\u4ee5\u5916\u3067\u3082\u52d5\u304b\u3059\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u88dc\u8db3\u3067\u3059\u304c\u3001WSGI\u30b5\u30fc\u30d0\u30fc\u306b\u306fuWSGI\u4ee5\u5916\u306bGunicorn\u3068\u3044\u3046\u3082\u306e\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>Web\u30b5\u30fc\u30d0\u3068\u306e\u9023\u643a<\/h3>\n<p>uWSGI\u306f\u52d5\u4f5c\u3055\u305b\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068Web\u30b5\u30fc\u30d0\u30fc\u3068\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3067\u901a\u4fe1\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>UNIX\u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8<\/li>\n<li>HTTP<\/li>\n<\/ul>\n<p>UNIX\u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8\u306f\u9ad8\u901f\u3067AP\u30b5\u30fc\u30d0\u30fc\u3068Web\u30b5\u30fc\u30d0\u30fc\u9593\u306e\u901a\u4fe1\u3092\u884c\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u76f4\u63a5\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u305f\u308a\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u30c8\u30e9\u30d6\u30eb\u304c\u8d77\u304d\u305f\u969b\u306b\u306f\u8abf\u67fb\u304c\u96e3\u822a\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>HTTP\u306f\u30bd\u30b1\u30c3\u30c8\u901a\u4fe1\u3088\u308a\u901f\u5ea6\u9762\u3067\u52a3\u308a\u307e\u3059\u304c\u3001\u6700\u8fd1\u306e\u30b5\u30fc\u30d0\u30fc\u306f\u4f4e\u4fa1\u683c\u306a\u3082\u306e\u3067\u3082\u305d\u3053\u305d\u3053\u6027\u80fd\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u5185\u90e8\u306e\u901a\u4fe1\u3067HTTP\u3092\u4f7f\u7528\u3057\u3066\u3082\u305d\u308c\u307b\u3069\u554f\u984c\u306b\u306a\u3089\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<a href=\"https:\/\/proxy.goincop1.workers.dev:443\/http\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_web.png\"><img loading=\"lazy\" src=\"https:\/\/proxy.goincop1.workers.dev:443\/http\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_web.png\" alt=\"\" width=\"1158\" height=\"436\" class=\"alignnone size-full wp-image-1981\" srcset=\"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_web.png 1158w, https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_web-300x113.png 300w, https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_web-768x289.png 768w, https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_web-1024x386.png 1024w\" sizes=\"(max-width: 1158px) 100vw, 1158px\" \/><\/a>\n<p>\u307e\u305f\u3001\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u304c\u306a\u3044API\u306e\u5834\u5408\u306fWeb\u30b5\u30fc\u30d0\u30fc\u3092\u7d4c\u7531\u305b\u305a\u306b\u3001\u76f4\u63a5\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3068\u901a\u4fe1\u3059\u308b\u306e\u3082\u4e00\u3064\u306e\u624b\u3067\u3057\u3087\u3046\u3002<\/p>\n<a href=\"https:\/\/proxy.goincop1.workers.dev:443\/http\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_only.png\"><img loading=\"lazy\" src=\"https:\/\/proxy.goincop1.workers.dev:443\/http\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_only.png\" alt=\"\" width=\"1134\" height=\"428\" class=\"alignnone size-full wp-image-1980\" srcset=\"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_only.png 1134w, https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_only-300x113.png 300w, https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_only-768x290.png 768w, https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/11\/uwsgi_only-1024x386.png 1024w\" sizes=\"(max-width: 1134px) 100vw, 1134px\" \/><\/a>\n<h3>uWSGI\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>Python\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u74b0\u5883\u3067\u3042\u308c\u3070\u3001pip\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npip install uWSGI\r\n<\/pre>\n<h2>uWSGI\u3067Flask\u3092\u52d5\u304b\u3057\u3066\u307f\u308b<\/h2>\n<p>\u305d\u308c\u3067\u306f\u3001\u3053\u3053\u304b\u3089\u5b9f\u969b\u306bWSGI\u306b\u6e96\u62e0\u3057\u305fFlask\u3092uWSGI\u3067\u52d5\u304b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002Flask\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3082\u5408\u308f\u305b\u3066\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/proxy.goincop1.workers.dev:443\/http\/www.python.ambitious-engineer.com\/archives\/1630\">Flask\u5165\u9580<\/a><\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n<p>\u3042\u3089\u304b\u3058\u3081Flask\u3068uWSGI\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npip install uWSGI\r\npip install flask\r\n<\/pre>\n<p>\u6b21\u306bFlask\u306e\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002run.py\u3068\u3044\u3046\u540d\u524d\u3067\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# run.py\r\nfrom flask import Flask, jsonify\r\n\r\napp = Flask(__name__)\r\n\r\n\r\n@app.route('\/')\r\ndef api_sample():\r\n    &quot;&quot;&quot;\r\n    API\u30b5\u30f3\u30d7\u30eb\r\n    :return:\r\n    &quot;&quot;&quot;\r\n    result = {&quot;code&quot;: &quot;001&quot;, &quot;name&quot;: &quot;apple&quot;}\r\n    return jsonify(ResultSet=result)\r\n\r\n\r\nif __name__ == '__main__':\r\n    app.run()\r\n\r\n<\/pre>\n<p>\/\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001json\u3092\u8fd4\u3059\u3060\u3051\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<code>python run.py <\/code>\u3068\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u30b5\u30fc\u30d0\u30fc\u304c\u8d77\u52d5\u3057\u307e\u3059\u306e\u3067\u3001\"https:\/\/proxy.goincop1.workers.dev:443\/http\/127.0.0.1:5000\/\"\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002json\u304c\u8fd4\u3055\u308c\u308c\u3070OK\u3067\u3059\u3002\u78ba\u8a8d\u304c\u7d42\u308f\u308c\u3070Ctrl+c\uff08Windows\u7cfb\u306e\u65b9\u306fctrl+z\uff09\u3067\u30b5\u30fc\u30d0\u30fc\u3092\u4e2d\u65ad\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>uWSGI\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c<\/h3>\n<p>\u6b21\u306buWSGI\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nuwsgi --http=0.0.0.0:8080 --wsgi-file=run.py  --callable=app\r\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3084curl\u30b3\u30de\u30f3\u30c9\u3067https:\/\/proxy.goincop1.workers.dev:443\/http\/127.0.0.1:8080\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5148\u7a0b\u306ejson\u304c\u51fa\u529b\u3055\u308c\u308c\u3070uWSGI\u7d4c\u7531\u3067\u306e\u5b9f\u884c\u306f\u6210\u529f\u3067\u3059\u3002<\/p>\n<p>uWSGI\u30b3\u30de\u30f3\u30c9\u3067\u306f\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002http\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3059\u308b\u30db\u30b9\u30c8\u3068\u30dd\u30fc\u30c8\u3092\u3001wsgi-file\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u306fwsgi\u3067\u52d5\u4f5c\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h3>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u5b9f\u884c\u3059\u308b<\/h3>\n<p>\u3055\u3066\u3001\u5b9f\u904b\u7528\u3067\u30b5\u30fc\u30d0\u30fc\u3092\u52d5\u304b\u3059\u5834\u5408\u3001\u4e0a\u8a18\u3067\u6307\u5b9a\u3057\u305f\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u30db\u30b9\u30c8\u3001\u30dd\u30fc\u30c8\u756a\u53f7\u4ee5\u5916\u306b\u3082\u3001\u30d7\u30ed\u30bb\u30b9\u6570\u3001\u30b9\u30ec\u30c3\u30c9\u6570\u3001\u5b9f\u52b9\u30e6\u30fc\u30b6\u30fc\u3001\u5b9f\u52b9\u30b0\u30eb\u30fc\u30d7\u3001\u30ea\u30ed\u30fc\u30c9\u65b9\u5f0f\u3001\u30bd\u30b1\u30c3\u30c8\u51fa\u529b\u5148\u3001\u6a29\u9650\u3001\u30ed\u30b0\u51fa\u529b\u5f62\u5f0f\u3001\u51fa\u529b\u5148\u3001etc...\u306a\u3069\u306a\u3069\u69d8\u3005\u306a\u9805\u76ee\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u5168\u3066\u30b3\u30de\u30f3\u30c9\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u9577\u3059\u304e\u3066\u53d6\u308a\u56de\u3057\u304c\u60aa\u3044\u3067\u3059\u306d\u3002\u3053\u306e\u305f\u3081\u3001\u5927\u62b5\u306e\u30b5\u30fc\u30d3\u30b9\u7cfb\u30b3\u30de\u30f3\u30c9\u3068\u540c\u69d8\u3001uWSGI\u30b3\u30de\u30f3\u30c9\u306f\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3072\u3068\u307e\u3068\u3081\u306b\u8a18\u8ff0\u3067\u304d\u308b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3067\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002uwsgi.ini\u3068\u3044\u3046ini\u5f62\u5f0f\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30bb\u30af\u30b7\u30e7\u30f3\u540d\u306f[uwsgi]\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# uwsgi.ini\r\n\r\n[uwsgi]\r\n\r\n# wsgi\u30d5\u30a1\u30a4\u30eb\r\nwsgi-file=run.py\r\ncallable=app\r\n\r\n# \u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u30db\u30b9\u30c8:\u30dd\u30fc\u30c8\r\nhttp=0.0.0.0:8080\r\n\r\n<\/pre>\n<p>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u304c\u5b8c\u6210\u3057\u305f\u3089\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nuwsgi uwsgi.ini\r\n<\/pre>\n<p>\u5148\u7a0b\u3068\u540c\u69d8\u3001https:\/\/proxy.goincop1.workers.dev:443\/http\/127.0.0.1:8080 \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u51fa\u529b\u3092\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>uWSGI\u306e\u8a2d\u5b9a\u9805\u76ee<\/h2>\n<p>\u6b21\u306b\u3001\u5b9f\u969b\u306b\u30b5\u30fc\u30d0\u30fc\u3068\u3057\u3066\u52d5\u304b\u3059\u5834\u5408\u306e\u8a2d\u5b9a\u5024\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002\u3044\u305a\u308c\u3082Centos\u7b49\u306eUnix\u7cfb\u30b5\u30fc\u30d0\u3067\u52d5\u304b\u3059\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30c7\u30fc\u30e2\u30f3\u5316<\/h3>\n<p>\u5148\u7a0b\u5b9f\u884c\u3057\u305f\u969b\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u4e0a\u306b\u30ed\u30b0\u304c\u51fa\u529b\u3055\u308c\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3092\u7d42\u4e86\u3059\u308b\u3068\u30b5\u30fc\u30d3\u30b9\u3082\u505c\u6b62\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u304c\u3001\u4ee5\u4e0b\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u30c7\u30fc\u30e2\u30f3\u5316\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndaemonize = \/var\/log\/uwsgi.log\r\nlog-reopen = true\r\nlog-maxsize = 8000000\r\nlogfile-chown = on\r\nlogfile-chmod = 644\r\n<\/pre>\n<p>log-reopen\u30ea\u30ed\u30fc\u30c9\u5f8c\u306b\u30ed\u30b0\u3092\u30ea\u30aa\u30fc\u30d7\u30f3\u3057\u307e\u3059\u3002log-maxsize\u306f\u30ed\u30b0\u306e\u6700\u5927\u30b5\u30a4\u30ba\u3067\u305d\u308c\u3092\u8d85\u904e\u3059\u308b\u3068\u30ed\u30fc\u30c6\u30fc\u30c8\u3055\u308c\u307e\u3059\u304c\u3001Linux\u306e\u30ed\u30b0\u30ed\u30fc\u30c6\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u65e5\u4ed8\u3092\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndaemonize = \/var\/log\/uWSGI-@(exec:\/\/date +%%Y-%%m-%%d).log\r\n<\/pre>\n<h3>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/h3>\n<p>\u4e0a\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u5b9f\u884c\u3057\u307e\u3057\u305f\u304c\u3001chdir\u3067WSGI\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u914d\u7f6e\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8a2d\u5b9a\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\/opt\/apps\/current\/sample_api\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u914d\u7f6e\u3057\u305f\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncurrent_release = \/opt\/apps\/current\/sample_api\r\nchdir = %(current_release)\r\nwsgi-file=%(current_release)\/run.py\r\n<\/pre>\n<p>\u4e0a\u306ecurrent_release\u306f\u5909\u6570\u3068\u306a\u3063\u3066\u304a\u308a\u3001%(current_release)\u3067\u4ed6\u306e\u9805\u76ee\u3067\u4f7f\u3044\u56de\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u5b9f\u52b9\u30e6\u30fc\u30b6\u30fc\u30fb\u30b0\u30eb\u30fc\u30d7<\/h3>\n<p>\u5b9f\u52b9\u30e6\u30fc\u30b6\u30fc\u3001\u30b0\u30eb\u30fc\u30d7\u306fuid\u3001gid\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nuid = uwsgi_user\r\ngid = uwsgi_group\r\n<\/pre>\n<h3>\u30d7\u30ed\u30bb\u30b9\u3001\u30b9\u30ec\u30c3\u30c9<\/h3>\n<p>processes\u3001threads\u3067\u30d7\u30ed\u30bb\u30b9\u6570\u3001\u30b9\u30ec\u30c3\u30c9\u6570\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002thunder-lock\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u308b\u30d7\u30ed\u30bb\u30b9\u3092\u5206\u6563\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002max-requests\u3067\u6307\u5b9a\u3057\u305f\u56de\u6570\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u308b\u3068\u30ea\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u4e00\u6589\u306b\u30ea\u30ed\u30fc\u30c9\u3059\u308b\u3068\u305d\u306e\u9593\u30b5\u30fc\u30d3\u30b9\u304c\u6b62\u307e\u308a\u307e\u3059\u306e\u3067\u3001max-requests-delta\u3067\u30ea\u30ed\u30fc\u30c9\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u306b\u30d7\u30ed\u30bb\u30b9\u3054\u3068\u306b\u5dee\u3092\u8a2d\u3051\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nprocesses = 4\r\nthreads = 2\r\nthunder-lock = true\r\nmax-requests = 3000\r\nmax-requests-delta = 300\r\nmaster = True\r\n<\/pre>\n<h2>uWSGI\u306e\u505c\u6b62\u3001\u518d\u8d77\u52d5\u3001\u30ea\u30ed\u30fc\u30c9<\/h2>\n<p>\u30c7\u30fc\u30e2\u30f3\u5316\u3057\u305fuwsgi\u3092\u505c\u6b62\u3001\u30ea\u30ed\u30fc\u30c9\u3059\u308b\u306b\u306fpid\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981\u3067\u3059\u3002\u8a2d\u5b9a\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# pid\u30d5\u30a1\u30a4\u30eb\u306e\u4f4d\u7f6e\u3092\u6307\u5b9a\r\npidfile = \/var\/run\/uwsgi\/uwsgi.pid\r\n# \u524d\u56de\u7570\u5e38\u7d42\u4e86\u3057\u305f\u5834\u5408\u3001\u8d77\u52d5\u6642\u306bpid\u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30a2\r\nvacuum = true\r\n<\/pre>\n<h3>\u505c\u6b62<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nuwsgi --stop \/var\/run\/uwsgi\/uwsgi.pid\r\n<\/pre>\n<h3>\u30ea\u30ed\u30fc\u30c9<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nuwsgi --reload \/var\/run\/uwsgi\/uwsgi.pid\r\n<\/pre>\n<p>\u307e\u305f\u3001\u30d7\u30ed\u30bb\u30b9ID\u304c\u308f\u304b\u3063\u3066\u3044\u308c\u3070\u30b7\u30b0\u30ca\u30eb\u3067\u3082\u64cd\u4f5c\u53ef\u80fd\u3067\u3059\u3002SIGHUP\u306e\u5834\u5408\u3001reload\u3068\u540c\u3058\u52d5\u4f5c\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nkill -HUP `cat \/var\/run\/uwsgi\/uwsgi.pid`\r\n<\/pre>\n<p>&nbsp;<br \/>\n<br \/>&nbsp;<\/p>\n<p>\u4eca\u56de\u306fuWSGI\u306b\u3064\u3044\u3066\u6982\u8981\u3092\u8aac\u660e\u3057\u307e\u3057\u305f\u3002\u6b21\u56de\u306fLinux\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067uWSGI\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3059\u308b\u4e88\u5b9a\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u3067Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u305f\u5f8c\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067\u7a3c\u50cd\u3055\u305b\u308b\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002\uff08\u958b\u767a\u6642\u306f\u7d44\u307f\u8fbc\u307f\u306e\u30b5\u30fc\u30d0\u30fc\u3067\u5341\u5206\u3067\u3059\u304c\u3001\u672c\u756a\u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\uff09\u3053\u3053\u3067\u306fPython...<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1959"}],"collection":[{"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=1959"}],"version-history":[{"count":17,"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1959\/revisions"}],"predecessor-version":[{"id":2021,"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1959\/revisions\/2021"}],"wp:attachment":[{"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=1959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=1959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=1959"}],"curies":[{"name":"wp","href":"https:\/\/proxy.goincop1.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}