如何在没有systemd的Linux Amazon中设置.NET Core应用程序

时间:2017-08-16 15:47:44

标签: linux amazon-web-services .net-core systemd

在Ubuntu 16.04上发布.NET Core应用程序时,我需要一种方法将应用程序作为服务运行,以便可以轻松管理并在失败时自动重新启动。有关如何在Microsoft's official docs website执行此操作的指南。推荐的方法是使用我已成功使用多次的systemd命令。但是我决定在AWS上托管我的.NET Core项目,并决定使用基于RedHat的Amazon Linux发行版,它没有systemd命令。以下是我之前在Ubuntu服务器上创建服务配置的方法。

基本上我要求一种将我的.NET Core应用程序设置为服务的等效方法以及用于管理它的等效命令(启动,重启,停止)

[Unit]
Description=Example .NET Web API Application running on Ubuntu

[Service]
WorkingDirectory=/var/aspnetcore/hellomvc
ExecStart=/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll
Restart=always
RestartSec=10  # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production 

[Install]
WantedBy=multi-user.target

编辑:从评论中我已经意识到我要找的东西叫做init系统。我用Google搜索" Linux Amazon init"并发现Linux Amazon中使用的默认初始化系统是" upstart"。以下是我在aws forum

中找到答案的来源

0 个答案:

没有答案