.NET Core bin 路径在 Amazon Linux 2 上随机变化
我们使用 AWS Auto Scaling 在 Amazon Linux 2 中部署 ASP.NET Core 应用程序
创建 Linux 服务时,dotnet 二进制文件的路径配置为:ExecStart=/usr/bin/dotnet ...
该路径一直运行良好,直到几个月前,在新的自动缩放实例上,dotnet 二进制路径随机更改为 /usr/bin/local/dotnet
,强制使用新路径更新 systemd 服务文件。
今天,我们的一个实例被 AWS 刷新为新实例,但服务没有启动,因为 bin 路径再次更改为 /usr/bin/dotnet
我无法在文档或更改日志中找到为什么要更改此二进制路径。
作为参考,ASP.NET Core 通过安装脚本自动安装在实例上,其中包含:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install -y aspnetcore-runtime-5.0
我们正在将应用程序更新到 .NET 6,因为 .NET 5 将不再获得支持,但我不这样做认为这将是这个问题的原因。
关于为什么这条路径被随机改变的任何见解?
如果无法阻止这种情况,有什么方法可以在 .service 文件中指定在找到的任何路径上使用 dotnet 吗?我认为设置 ExecStart=dotnet ...
将找不到二进制文件。
We deploy our ASP.NET Core applications in Amazon Linux 2 using AWS Auto Scaling
When the linux services were created, the path for the dotnet binary was configured as: ExecStart=/usr/bin/dotnet ...
That path worked fine until some months ago, on new auto scaled instances the dotnet binary path randomly changed to /usr/bin/local/dotnet
forcing to update the systemd service files with the new path.
Today one of our instances was refreshed with a new one by AWS and the services didn't start because the bin path changed again to /usr/bin/dotnet
I am unable to find in documentation or changelogs on why this binary path is being changed.
For reference, ASP.NET Core is being installed automatically on the instances by an install script containing:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install -y aspnetcore-runtime-5.0
We're in the process of updating our application to .NET 6 as .NET 5 will no longer be receiving support, but I don't think that would be the cause for this issue.
Any insights on why this path is being changed randomly?
If this can't be prevented, any way to specify in the .service file to use dotnet on whichever path it's found? I think that setting ExecStart=dotnet ...
will not find the binary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能在安装脚本中弄清楚吗?
比如用
--DOTNET_PATH--
填充路径。以正常方式安装 dotnet,然后使用
which dotnet
并替换它。服务文件
安装脚本
或者,找出存在哪个文件,然后将一个文件符号链接到另一个文件也可以。
Could you just figure it out in the installation script?
Something like filling the path with
--DOTNET_PATH--
.Installing dotnet the normal way and then using
which dotnet
and replacing it.The Service file
The installation script
Alternatively, figuring it out which file exists and then symlinking one to the other would also work.