dll文件更改时重新加载ASP.NET Core应用(bin部署) [英] Reload ASP.NET Core app when dll files change (bin deploy)

查看:305
本文介绍了dll文件更改时重新加载ASP.NET Core应用(bin部署)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:ASP.NET Core 2.1,Ubuntu.

Environment: ASP.NET Core 2.1, Ubuntu.

在旧式ASP.NET中,当我进行bin部署(例如,上载了一些dll文件)时,webapp会检测到该情况并重新加载自身-非常有用.

In old style ASP.NET, when I did a bin deploy (uploaded some dll files for example), the webapp would detect that and reload itself - very useful.

使用Core不能做到这一点.我需要停止并重新启动dotnet MyApp.dll进程.

With Core it doesn't do that. I need to stop and restart the dotnet MyApp.dll process.

如何使它检测二进制文件的更改并重新加载?

How do I make it detect changes to binaries and reload?

推荐答案

据我所知,没有什么可以为您完成的. IIS监视bin目录,web.config等内容,并在检测到更改时回收应用程序池,但这是因为它知道.它也是功能齐全的Web服务器,对文件更改进行回收的App Pool是这些功能之一.红est,我假设您使用的是 not .这是一个非常简单的Web服务器,它可以像严格意义上的Web服务器一样执行所需的操作.这就是为什么像IIS,Apache,Nginx等更传统的Web服务器通常用作Kestrel前面的反向代理-提供更多高级功能的原因.

There's nothing I'm aware of that will do this for you. IIS watches things like the bin directory, web.config, etc. and recycles the App Pool when it detects changes, but that's because it knows to. It's also a full-featured web server, and App Pool recycling on file changes is one of those features. Kestrel, which I assume your using is not. It's a very simple web server that does just what it needs to do as strictly a web server. That's why a more traditional web server like IIS, Apache, Nginx, etc. is normally used as a reverse proxy in front of Kestrel - to provide more advanced functionalities.

尽管如此,这实际上只是您的发布策略的问题.就个人而言,我鼓励您使用比粘贴粘贴DLL更强大的功能,但是如果您要采用这种方式,还可以 script .创建一个Shell脚本来复制bin目录,然后重新启动您的应用程序.您的发布应该尽可能地是一条轨道.每次需要人工干预时,您都有潜在的失败点,因为人类天生就容易犯错.但是,脚本一旦经过测试并确保可以正常工作,则每次都会工作很多,因为它总是以相同的顺序执行相同的事情.

All that said, though, this is really just a matter of your release strategy. Personally, I'd encourage you to go with something far more robust that copy-pasting DLLs, but if you want to go that route, you can also script it. Create a shell script to copy the bin directory and restart your app. Your release should be one rails as much as possible. Every time human intervention is called for, you have a potential point of failure, because humans are inherently fallible. A script, however, once tested and ensured to work, will pretty much work every time, because it always does the same things in the same order.

这篇关于dll文件更改时重新加载ASP.NET Core应用(bin部署)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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