0

我收到以下错误:

Jun 03 06:41:04 {my_digital_ocean_server} systemd[13752]: kestrel-hellomvc.service: Failed at step CHDIR spawning /usr/bin/dotnet: No such file or directory
-- Subject: Process /usr/bin/dotnet could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /usr/bin/dotnet could not be executed and failed.

运行时:

systemctl start kestrel-hellomvc.service

遵循本指南: https ://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction

运行:nano /usr/bin/dotnet为我获取一个包含内容的大文件,并which dotnet返回 /usr/bin/dotnet,因此该文件确实存在(?)。

为什么我会收到此错误,解决方案是什么?

编辑:我的 /etc/systemd/system/kestrel-hellomvc.service 文件:

[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=root
Environment=ASPNETCORE_ENVIRONMENT=Production 

[Install]
WantedBy=multi-user.target
4

2 回答 2

1

which dotnet

为您的应用服务文件/etc/systemd/system/kestrel-MyAppName.service属性找到正确的路径

ExecStart=/bin/dotnet /var/www/dev-slc1.almw.local/public_html/MyAppName.dll

例如在 CentOS7 上的which dotnet结果如下:/bin/dotnet.

于 2019-03-29T03:18:52.153 回答
1

dotnet 可能不在 usr/bin 中。在 Ubuntu Server 16.04 上,我的位于 /usr/share/dotnet 并且服务文件中的可执行行是 /usr/share/dotnet/dotnet。

于 2018-02-14T22:34:18.793 回答