简体   繁体   English

在CentOS 8上使用Postgres,Nginx和Gunicorn配置Django之后,无论我如何更改Django,都没有变化

[英]After configure Django with Postgres, Nginx, and Gunicorn on CentOS 8,no matter how i change the Django ,there has no change

Recently I configure the web server as the guide of this link: 最近,我将Web服务器配置为该链接的指南:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7#create-a-python-virtual-environment-for-your-project https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7#create-a-python-virtual-environment-为您的项目

I can normally visit the homepage like: the normal page AND I can normal visit domain_name/admin . 我通常可以正常访问首页,例如: 普通页面 ,我也可以正常访问domain_name / admin。

After that ,when i create my_apps,even i change the url this: 之后,当我创建my_apps时,即使我更改网址,也可以这样:

from django.conf.urls import url,include
from django.contrib import admin

urlpatterns = [

]

Once i visit the domain_name or domain_name/admin or IP/admin,there has no change.There has no warning and no change 一旦我访问了domain_name或domain_name / admin或IP / admin,就没有任何变化。没有警告也没有变化

每次更改后,您都需要重新启动gunicorn ,因为自动重新加载仅在运行开发服务器和manage.py runserver

If you don't want to manually restart gunicorn after each change, you could use reload in settings, but keep in mind: 如果您不想在每次更改后手动重启gunicorn ,可以在设置中使用reload ,但请注意:

This setting is intended for development. 此设置用于开发。 It will cause workers to be restarted whenever application code changes. 每当应用程序代码更改时,它将导致工作程序重新启动。

The reloader is incompatible with application preloading. 重新加载程序与应用程序预加载不兼容。 When using a paste configuration be sure that the server block does not import any application code or the reload will not work as designed. 使用粘贴配置时,请确保服务器块不导入任何应用程序代码,否则重新加载将无法按设计进行。

You'll need to restart gunicorn automatically each time as already have been noted. 如前所述,您需要每次自动重新启动gunicorn。

You also may consider using Supervisor or Monit to restart gunicorn automatically, I have such experience with Flask applications. 您也可以考虑使用Supervisor或Monit自动重启gunicorn,我对Flask应用程序有这样的经验。

Take a look here for few examples, maybe they will help you. 在这里看看一些示例,也许它们会为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM