如何获得Bottle在文件更改时重新启动? [英] How can I get Bottle to restart on file change?

查看:125
本文介绍了如何获得Bottle在文件更改时重新启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我真的很喜欢瓶子,但是事实上,我必须从服务器中按CTRL + C每次更改代码后重新启动它,对我的工作效率来说是一个很大的打击.我曾考虑过使用 Watchdog 来跟踪文件的更改,然后重新启动服务器,但是我该怎么办?在bottle.run函数被阻止时执行此操作.

I'm really enjoying Bottle so far, but the fact that I have to CTRL+C out of the server and restart it every time I make a code change is a big hit on my productivity. I've thought about using Watchdog to keep track of files changing then restarting the server, but how can I do that when the bottle.run function is blocking.

从监视文件更改的外部脚本运行服务器似乎需要进行大量工作.我认为这对于Bottle,CherryPy等开发人员来说是一个普遍的问题.

Running the server from an external script that watches for file changes seems like a lot of work to set up. I'd think this was a universal issue for Bottle, CherryPy and etcetera developers.

感谢您对问题的解决方案!

Thanks for your solutions to the issue!

推荐答案

从教程中检出标题为自动重新加载"

在开发过程中,您必须大量重启服务器才能测试您的 近期变动.自动重新加载器可以为您完成此任务.每次你 编辑模块文件,重新加载程序重新启动服务器进程并加载 最新版本的代码.

During development, you have to restart the server a lot to test your recent changes. The auto reloader can do this for you. Every time you edit a module file, the reloader restarts the server process and loads the newest version of your code.

这给出了以下示例:

from bottle import run
run(reloader=True)

这篇关于如何获得Bottle在文件更改时重新启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆