Django runserver 默认多线程 监听文件变动
django-admin and manage.py | Django documentation | Django https://docs.djangoproject.com/en/3.0/ref/django-admin/#runserver
runserver¶
django-admin runserver [addrport]¶
Starts a lightweight development Web server on the local machine. By default, the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an IP address and port number explicitly.
If you run this script as a user with normal privileges (recommended), you might not have access to start a port on a low port number. Low port numbers are reserved for the superuser (root).
This server uses the WSGI application object specified by the WSGI_APPLICATION setting.
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)
The development server automatically reloads Python code for each request, as needed. You don’t need to restart the server for code changes to take effect. However, some actions like adding files don’t trigger a restart, so you’ll have to restart the server in these cases.
If you’re using Linux or MacOS and install both pywatchman and the Watchman service, kernel signals will be used to autoreload the server (rather than polling file modification timestamps each second). This offers better performance on large projects, reduced response time after code changes, more robust change detection, and a reduction in power usage. Django supports pywatchman 1.2.0 and higher.
Large directories with many files may cause performance issues
When using Watchman with a project that includes large non-Python directories like node_modules, it’s advisable to ignore this directory for optimal performance. See the watchman documentation for information on how to do this.
Watchman timeout
The default timeout of Watchman client is 5 seconds. You can change it by setting the DJANGO_WATCHMAN_TIMEOUT environment variable.
Watchman support replaced support for pyinotify.
When you start the server, and each time you change Python code while the server is running, the system check framework will check your entire Django project for some common errors (see the check command). If any errors are found, they will be printed to standard output.
You can run as many concurrent servers as you want, as long as they’re on separate ports by executing django-admin runserver more than once.
Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or0.0.0.0 or :: (with IPv6 enabled).
You can provide an IPv6 address surrounded by brackets (e.g. [200a::1]:8000). This will automatically enable IPv6 support.
A hostname containing ASCII-only characters can also be used.
If the staticfiles contrib app is enabled (default in new projects) the runserver command will be overridden with its own runserver command.
Logging of each request and response of the server is sent to the django.server logger.
--noreload¶
Disables the auto-reloader. This means any Python code changes you make while the server is running will not take effect if the particular Python modules have already been loaded into memory.
--nothreading¶
Disables use of threading in the development server. The server is multithreaded by default.
--ipv6,-6¶
Uses IPv6 for the development server. This changes the default IP address from 127.0.0.1 to ::1.
Examples of using different ports and addresses¶
Port 8000 on IP address 127.0.0.1:
django-admin runserver
Port 8000 on IP address 1.2.3.4:
django-admin runserver 1.2.3.4:8000
Port 7000 on IP address 127.0.0.1:
django-admin runserver 7000
Port 7000 on IP address 1.2.3.4:
django-admin runserver 1.2.3.4:7000
Port 8000 on IPv6 address ::1:
django-admin runserver -6
Port 7000 on IPv6 address ::1:
django-admin runserver -6 7000
Port 7000 on IPv6 address 2001:0db8:1234:5678::9:
django-admin runserver [2001:0db8:1234:5678::9]:7000
Port 8000 on IPv4 address of host localhost:
django-admin runserver localhost:8000
Port 8000 on IPv6 address of host localhost:
django-admin runserver -6 localhost:8000
Django runserver 默认多线程 监听文件变动的更多相关文章
- node.js监听文件变化
前言 随着前端技术的飞速发展,前端开发也从原始的刀耕火种,向着工程化效率化的方向发展.在各种开发框架之外,打包编译等技术也是层出不穷,开发体验也是越来越好.例如HMR,让我们的更新可以即时可见,告别了 ...
- oracle 监听文件 说明
MAR:电脑笔记 不做整理 .. ORACLE_SID=orcl2 instance_name=sicca 静态注册文件中SID_NAME=ORACLE_SID 动态注册的时候是用的instance_ ...
- 如何使用NodeJs来监听文件变化
1.前言 在我们调试修改代码的时候,每修改一次代码,哪怕只是很小的修改,我们都需要手动重新build文件,然后再运行代码,看修改的效果,这样的效率特别低,对于开发者来说简直不能忍. 2.构建自动编译工 ...
- c# 监听文件夹动作
static FileSystemWatcher watcher = new FileSystemWatcher(); /// <summary> /// 初始化监听 ...
- java多线程监听JMS、MQ队列
本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可. 转载请注明出处和作者.http://blog.csdn.net/xtj332 背景:消息队列中有非常多的消息需要 ...
- 【Oracle】环境变量与监听文件
一.环境变量的及其含义: 数据库主目录 ORACLE_HOME=D:\app\Administrator\product\11.2.0\dbhome_1 监听文件所在目录 TNS_ADMIN=D:\a ...
- 利用Node的chokidar 监听文件改变的文件。
最近维护一个项目.每次改完东西,都要上传到服务器.然后有时候就忘记一些东西,于是就想有没有可以方法能监听文件的改变.然后我再利用程序把更改的文件一键上传到服务器. 于是就找到了nodejs 的chok ...
- SpringMVC 监听文件上传进度
Spring MVC 监听文件上传进度 具体实现分三个步骤: 接管CommonsMultipartResolver,重写针对文件上传的请求. 在第一步中写入监听,以获取上传进度. 修改上传部分的配置文 ...
- 使用Node.JS监听文件夹变化
使用Node.JS监听文件夹改变有许多应用场合,比如: 构建自动编绎工具 当源文件改变时,自动运行build过程,比如当你写CoffeeScript文件或SASS CSS文件时,保存之后可即时生成对应 ...
随机推荐
- Kafka超详细学习笔记【概念理解,安装配置】
目录 本篇要点 Kafka介绍 作为流处理平台的三种特性 主要应用 四个核心API 基本术语 快速开始 安装配置Zookeeper 下载kafka 配置文件 Windows的命令 启动Zookeepe ...
- Dubbo服务调用过程源码解析④
目录 0.服务的调用 1.发送请求 2.请求编码 3.请求的解码 4.调用具体服务 5.返回调用结果 6.接收调用结果 Dubbo SPI源码解析① Dubbo服务暴露源码解析② Dubbo服务引用源 ...
- Springboot 源码解析-自定装配
面试官经常会问你知道springboot的自定装配吗?它是怎么实现的吗?今天我们就来通过源码一起分析下它吧.首先我们先搭建一个springboot的简单项目,找到启动类, 然后通过这个注解我们进入到@ ...
- 前端面试题归类-HTML1
一.HTML5的新特性? 1.增强了表单,input新增了一些type:常用 color----定义调色板 tel-----定义包含电话号码的输入域 email---定义包含email地址的输入域 s ...
- JavaSwing 船只停靠管理可视化(一)
最近抽空闲时间做了船只停靠管理系统,先看一下效果. 停靠泊位管理:实现泊位的 增删改查. JavaSwing 船只停靠管理可视化(一) JavaSwing 船只停靠管理可视化(二) JavaSwing ...
- 设计模式——从HttpServletRequestWrapper了解装饰者模式
从一个业务开始 最近项目上紧急需要,为了应付一个不知道啥的安全检测,我们要给系统追加防XSS注入的功能,这里有经验的JavaWeb开发就会想到,用过滤器或者基于项目框架的拦截器来做,但是顺着这个思路下 ...
- 当Thymeleaf遇到向js中传值的操作
在使用Thymeleaf的时候.关于一些点击操作非常头疼.往往需要向JS里面传递各种东西. 然而,在用Thymeleaf的时候.js操作需要拼接语句.但是又不好拼接. 关于一些操作,一般也是在表格中. ...
- 单细胞分析实录(2): 使用Cell Ranger得到表达矩阵
Cell Ranger是一个"傻瓜"软件,你只需提供原始的fastq文件,它就会返回feature-barcode表达矩阵.为啥不说是gene-cell,举个例子,cell has ...
- LVS、Nginx和HAProxy区别
LVS.Nginx和HAProxy区别 LVS 优点: 高并发连接:LVS基于内核网络层面工作,有超强的承载能力和并发处理能力.单台LVS负载均衡器,可支持上万并发连接. 抗负载能力强:是工作在网络4 ...
- Node项目模板管理脚手架ptm-cli开发
目录 一.ptm-cli 使用说明 1.特点 2.安装 3.使用 1)基础帮助命令 2)添加模板/项目 3)编辑模板/项目 4)查看模板/项目 5)删除模板/项目 6)基于模板新建/初始化项目 二 p ...