金字塔python框架修改源码后如何重启应用?
How to restart app when source code modified in pyramid python framework?
在金字塔框架中修改代码文件后,有什么方法可以重启应用程序吗?
pyramid.reload_templates
此变量适用于模板,但不适用于源代码。
我想重新启动项目作为修改为 nodemon npm 包的代码。
谢谢
如果您希望您的项目在代码更改时重新启动,那么您可能需要将其包装在一个重新加载函数中,该函数会监视您的文件并重新加载您的服务器。
有关示例代码段,请参阅 here。这最初取自 CherryPy 项目。
来自 Reloading Code 上的 Pyramid 文档(为了相关性而删减):
During development, it's often useful to run pserve
using its --reload
option. When --reload
is passed to pserve
, changes to any Python module your project uses will cause the server to restart. This typically makes development easier, as changes to Python code made within a Pyramid application is not put into effect until the server restarts.
$VENV/bin/pserve development.ini --reload
Changes to template files (such as .pt
or .mak
files) won't cause the server to restart. Changes to template files don't require a server restart as long as the pyramid.reload_templates
setting in the development.ini
file is true. Changes made to template files when this setting is true will take effect immediately without a server restart.
在金字塔框架中修改代码文件后,有什么方法可以重启应用程序吗?
pyramid.reload_templates
此变量适用于模板,但不适用于源代码。 我想重新启动项目作为修改为 nodemon npm 包的代码。 谢谢
如果您希望您的项目在代码更改时重新启动,那么您可能需要将其包装在一个重新加载函数中,该函数会监视您的文件并重新加载您的服务器。
有关示例代码段,请参阅 here。这最初取自 CherryPy 项目。
来自 Reloading Code 上的 Pyramid 文档(为了相关性而删减):
During development, it's often useful to run
pserve
using its--reload
option. When--reload
is passed topserve
, changes to any Python module your project uses will cause the server to restart. This typically makes development easier, as changes to Python code made within a Pyramid application is not put into effect until the server restarts.
$VENV/bin/pserve development.ini --reload
Changes to template files (such as
.pt
or.mak
files) won't cause the server to restart. Changes to template files don't require a server restart as long as thepyramid.reload_templates
setting in thedevelopment.ini
file is true. Changes made to template files when this setting is true will take effect immediately without a server restart.