• 欢迎访问db1024网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏db1024吧

Linux下.NET Core进程守护设置,解决SSH关闭后.NET Core服务无法问题

主机教程 Liam 1年前 (2019-07-03) 589次浏览 21个评论 扫描二维码

前段时间VPS234为大家讲解了Linux 部署.NET Core教程,但是之前有一个缺点就是当SSH连接断开后,.NET Core服务就断开了,这种肯定是不行了,今天VPS234就为大家讲解下.NET Core进程守护问题,教大家一步步设置Linux 下.NET Core的进程守护。

首先需要明确的是我们使用的Linux系统版本为Centos 7,其余Linux 操作系统类似。

安装Supervisor

首先分别执行下面的命令安装Supervisor

yum install python-setuptools

easy_install supervisor

配置Supervisor

使用下面的命令创建supervisor文件

mkdir /etc/supervisor

echo_supervisord_conf > /etc/supervisor/supervisord.conf

然后编辑supervisord.conf文件,将文件结尾处的文件:

[include]
   files = relative/directory/*.ini

替换为如下所示:

[include]
   [include]files = conf.d/*.conf

保存后退出。

进入 /etc/supervisor/ ,然后创建一个名为"conf.d"的文件夹,然后在改文件夹下创建一个名为"myproject.conf"文件,编辑的内容如下所示:

[program:myproject]
   command=dotnet VPS234-CoreTest.dll ; 运行程序的命令 VPS234-CoreTest.dll是我的.NET Core项目dll,你需要换成自己的
   directory=/ftp/ ; 你.NET Core的根目录
   autorestart=true ; 程序意外退出是否自动重启
   stderr_logfile=/var/log/myproject.err.log ; 错误日志文件
   stdout_logfile=/var/log/myproject.out.log ; 输出日志文件
   environment=ASPNETCORE_ENVIRONMENT=Production ; 进程环境变量
   user=root ; 进程执行的用户身份
   stopsignal=INT

然后保存文件退出,注意命令不能写错了。

运行supervisord

先执行下面的命令,运行

supervisord -c /etc/supervisor/supervisord.conf

然后查看supervisord运行状态,输入下面的命令:

ps -ef | grep myproject

然后看到如下效果图说明部署成功了,如下图所示:

Linux下.NET Core进程守护设置,解决SSH关闭后.NET Core服务无法问题

然后使用下面的命令重新加载配置:

supervisorctl reload

如果修改了myproject.conf文件的配置,那么重新用上面的重新加载命令重新启动就会重新生效。

以上就是Linux下.NET Core开启进程守护的教程,这样就可以解决关闭SSH连接后.NET Core进程不能运行的问题,如果有需要配置Linux .NET Core进程守护的朋友可以参考上面的教程解决。


db1024 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Linux下.NET Core进程守护设置,解决SSH关闭后.NET Core服务无法问题
喜欢 (1)
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(21)个小伙伴在吐槽
  1. Hello there! Do you know if they make any plugins to help with Search Engine Optimization? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good results. If you know of any please share. Kudos!
    web hosting companies2020-09-01 00:49 回复 Windows 8.1 | Firefox浏览器 60.0
  2. My brother suggested I might like this website. He was entirely right. This put up actually made my day. You cann't consider simply how much time I had spent for this information! Thanks!
    webhosting2020-08-31 21:36 回复 Mac OS X | Firefox浏览器 56.0.4
  3. I truly love your website.. Pleasant colors & theme. Did you build this web site yourself? Please reply back as I'm attempting to create my own site and would love to learn where you got this from or just what the theme is named. Cheers!
    black mass2020-08-31 06:59 回复 Mac OS X | Firefox浏览器 61.0
  4. Useful information. Lucky me I found your site unintentionally, and I'm stunned why this accident didn't happened earlier! I bookmarked it.
    black mass2020-08-28 18:55 回复 Windows 8.1 | Firefox浏览器 60.0
  5. My brother suggested I would possibly like this blog. He used to be entirely right. This put up actually made my day. You can not consider simply how much time I had spent for this information! Thank you!
    cheap flights2020-08-27 04:25 回复 Linux | Chrome 66.0.3359.106
  6. Thanks very nice blog!
    web hosting companies2020-08-25 22:30 回复 Linux | Chrome 66.0.3359.139
  7. This is a topic which is close to my heart... Cheers! Exactly where are your contact details though? cheap flights y2yxvvfw
    cheap flights2020-08-25 05:04 回复 Mac OS X | Chrome 66.0.3359.117
  8. This post will help the internet users for setting up new blog or even a blog from start to end. cheap flights yynxznuh
    cheap flights2020-08-24 22:21 回复 Linux | Firefox浏览器 56.0
  9. of course like your web-site however you need to check the spelling on several of your posts. A number of them are rife with spelling issues and I find it very bothersome to inform the truth however I will certainly come again again.
    best web hosting company2020-08-10 09:38 回复 Linux | Chrome 67.0.3396.62
  10. I'm no longer certain where you are getting your information, but good topic. I needs to spend some time studying much more or working out more. Thanks for wonderful information I was looking for this info for my mission.
    web hosting2020-08-07 20:53 回复 Linux | Chrome 66.0.3359.117
  11. You actually make it appear really easy with your presentation however I find this topic to be actually one thing that I think I would never understand. It sort of feels too complex and extremely wide for me. I'm looking forward for your subsequent publish, I will try to get the hold of it!
    website hosting services2020-08-07 01:39 回复 Mac OS X | Chrome 63.0.3239.132
  12. I believe that is one of the so much vital information for me. And i am glad reading your article. However should observation on some common things, The site style is great, the articles is really nice : D. Excellent task, cheers
    content hosting2020-08-06 03:08 回复 Linux | 未知浏览器
  13. Having read this I thought it was extremely enlightening. I appreciate you spending some time and energy to put this content together. I once again find myself personally spending a lot of time both reading and posting comments. But so what, it was still worthwhile!
    cheap flights to florida jetblue2020-07-31 11:00 回复 Linux | Chrome 52.0.2777.35
  14. This post gives clear idea designed for the new people of blogging, that truly how to do blogging. adreamoftrains web hosting providers
    adreamoftrains content hosting2020-07-30 20:49 回复 Linux | Chrome 66.0.3359.117
  15. This text is invaluable. When can I find out more?
    website hosting2020-07-27 03:27 回复 Linux | Firefox浏览器 2.0.0.6
  16. Hi, this weekend is pleasant for me, because this moment i am reading this wonderful educational article here at my residence.
    web hosting reviews2020-07-23 11:14 回复 Linux | Chrome 65.0.3325.109
  17. Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I've been trying for a while but I never seem to get there! Thank you
    web hosting reviews2020-07-18 05:49 回复 Linux | Chrome 59.0.3071.86
  18. Hello, its pleasant piece of writing about media print, we all be familiar with media is a fantastic source of information.
    web hosting sites2020-07-16 22:30 回复 Linux | Chrome 66.0.3359.139
  19. I like the valuable information you provide in your articles. I will bookmark your weblog and check again here frequently. I am quite sure I'll learn plenty of new stuff right here! Good luck for the next!
    cbd oil that works 20202020-06-29 06:07 回复 Linux | 未知浏览器
  20. Hi! I'm at work surfing around your blog from my new iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the fantastic work!
    cbd oil that works 20202020-06-28 08:56 回复 Linux | 未知浏览器
  21. Thank you, I've recently been looking for info approximately this subject for a while and yours is the greatest I've found out so far. But, what concerning the bottom line? Are you certain concerning the supply?
    g rsacwgxy2020-06-22 10:54 回复 Linux | Chrome 66.0.3359.181