ubuntu - 从 `systemd` 脚本运行的 `dotnet` 命令找不到 AspNetCore 3.0,但可以从命令行运行
问题描述
我有一个 linux ubuntu 16.04 服务器,用于托管一堆 .NET Core 站点和应用程序(它是一个登台服务器),还有一堆使用 .NET Core 2.0 和 2.1 的应用程序。服务器使用带有代理的 nginx 通过网络提供内容。
我刚刚部署了一个 ASP.NET Core 3.0 MVC 网站,按照此处的说明安装 ASP.NET Core 3.0 运行时,https://docs.microsoft.com/en-us/dotnet/core/install/linux-package -manager-ubuntu-1604。
如果我dotnet MyApp.dll
直接从命令行运行,它会启动并运行良好,在端口 5000 上提供服务,一切正常。但是,如果我尝试使用 systemd 服务启动应用程序,它将无法正常工作,并出现以下错误journalctl
:
Feb 11 13:57:18 ip-172-31-2-223 systemd[1]: Started IBA Showcase Test API.
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: It was not possible to find any compatible framework version
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: The specified framework 'Microsoft.AspNetCore.App', version '3.0.0' was not found.
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: - Check application dependencies and target a framework version installed at:
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: /usr/share/dotnet/
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: - Installing .NET Core prerequisites might help resolve this problem:
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: - The .NET Core framework and SDK can be installed from:
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: https://aka.ms/dotnet-download
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: - The following versions are installed:
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: 2.1.13 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Feb 11 13:57:18 ip-172-31-2-223 dotnet[19193]: 2.2.7 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
我在文件夹中的 .service 文件/etc/systemd/system
非常简单,如下所示:
[Unit]
Description=IBA Showcase Test API
Wants=network.target
[Service]
Type=simple
User=www-data
Group=www-data
Environment="DOTNET_CLI_TELEMETRY_OPTOUT=1"
Environment="ASPNETCORE_ENVIRONMENT=Staging"
Environment="ASPNETCORE_URLS=http://*:5000"
WorkingDirectory=/var/www/ibashowcase/api/
ExecStart=/usr/bin/dotnet IBA.Showcase.API.dll
Restart=on-failure
[Install]
WantedBy=multi-user.target
任何提示将不胜感激。
解决方案
推荐阅读
- jq - 使用 JQ 将 JSON 对象转换为数组
- python - 如何从选定的 Tkinter 单选按钮获取文本标签?
- python - 为什么django-q定时任务会随机延迟?
- json - availableFrom 没有可用值
- javascript - Javascript 对所有集合项执行代码
- go - Golang 中的后退箭头“<-”是什么?
- c++ - 如何在类主体之外定义类模板的模板化方法
- hive - 将 Impala 命令迁移到 Hive
- compiler-construction - elixir:eval_forms 和 elixir_compiler 中 compile 的区别
- flutter - ObjectBox Flutter:注销时清除所有表