简体   繁体   English

停止在kestrel上运行的运行dotnet核心网站

[英]Stop a running dotnet core website running on kestrel

When deploying a new version of an existing .net core website. 部署新版本的现有.net核心网站时。 How do I first safely stop the old running kestrel app? 我如何首先安全地停止旧的运行的茶隼应用程序?

Here is an exmaple of what I would like to write (Pseudo deployment script): 以下是我想写的内容(伪部署脚本):

dotnet stop mysite/mysite.dll <---- this line here
mv mysite/ mysite.bak/
cp newly-published-mysite/ mysite/
dotnet run mysite/mysite.dll

killall dotnet seems a little unsafe. killall dotnet似乎有点不安全。 How would it work if I were hosting two small sites on one box? 如果我在一个盒子上托管两个小网站,它会如何运作?

Accordingly to this discussion , there is no safe way to stop Kestrel now. 根据这个讨论 ,现在没有安全的方法来阻止红隼。 You need to find a PID by name of your dll and kill it : 您需要通过dll的名称找到一个PID并将其杀死

kill $(ps aux | grep 'MySite.dll' | awk '{print $2}')

In case of process tree, you need to manually grep all child IDs and call kill for each. 在进程树的情况下,您需要手动grep所有子ID并为每个子ID调用kill Like it was done in Microsoft.Extensions.Internal.ProcessExtensions.KillTree method (correct link from the discussion). 就像在Microsoft.Extensions.Internal.ProcessExtensions.KillTree方法中完成的那样(来自讨论的正确链接)。

I have decided to use supervisor to monitor and manage the process. 我决定使用主管来监控和管理流程。 Here is an excellent article on getting it set up . 这是一篇关于设置它的优秀文章

It allows simple control over specific dotnet apps like this: 它允许简单控制特定的dotnet应用程序,如下所示:

supervisorctl stop MyWebsiteName
supervisorctl start MyWebsiteName

And it has one huge advantage in that it can try restart the process if it falls over, or when the system reboots... for whatever reason. 它有一个巨大的优势,它可以尝试重新启动过程,如果它崩溃,或系统重新启动......无论出于何种原因。

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

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