【问题标题】:core-dump error when trying to run asp .netcore app under Ubuntu 16.04尝试在 Ubuntu 16.04 下运行 asp .net core 应用程序时出现 core-dump 错误
【发布时间】:2023-03-30 04:20:01
【问题描述】:

我正在尝试在 Ubuntu 16.04 下将我的 asp .net 核心应用程序作为服务运行。 我按照this 文档创建了服务配置

[Unit]
Description=TNW Main Service

[Service]
WorkingDirectory=/home/tnw
ExecStart=/usr/bin/dotnet /home/tnw/Tnw.MealsApi.dll
Restart=always
RestartSec=10
SyslogIdentifier=tnw
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production

[Install]
WantedBy=multi-user.target

我已启用我的服务:

sudo systemctl enable tnw.service

最后我尝试运行它,但我得到了异常:

● tnw.service - TNW Main Service Loaded: loaded (/etc/systemd/system/tnw.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: core-dump) since Tue 2019-09-10 12:57:20 CEST; 118ms ago
Process: 15160 ExecStart=/usr/bin/dotnet /home/tnw/Tnw.MealsApi.dll (code=dumped, signal=ABRT)
Main PID: 15160 (code=dumped, signal=ABRT)

Sep 10 12:57:20 server767126 systemd[1]: tnw.service: Unit entered failed state.
Sep 10 12:57:20 server767126 systemd[1]: tnw.service: Failed with result 'core-dump'.

当我手动运行这个应用程序时,它运行良好。

sudo dotnet Tnw.MealsApi.dll

//编辑我在日记中发现以下异常:

 System.Net.Sockets.SocketException (13): Permission denied

【问题讨论】:

  • 您好,您找到解决方案了吗?
  • 嗨,在我的情况下,问题与用户 wwwdata 没有使用端口 80 和 443 的权限有关,因此我使用了 root 用户作为解决方法。但这只是临时解决方案。我已经尝试了许多教程如何向其他用户添加权限但没有成功。
  • 您是否尝试过更改为非特权端口号,例如。 5000 然后在 iptables 中添加一个重定向,如下所示: sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 5000
  • 我会尝试,但我确定它是否可以使用。网络核心自动重定向。谢谢!
  • 我看到这个帖子有点老了,但我想问问你们中的一些人是否找到了解决这个问题的方法。就我而言,我在同一个容器中托管了一个网络核心 API 和一个 SignalR 服务。 API 正在从端口 5000(HTTP)、5001(HTTPS) 重定向。来自端口 5002(HTTP)、5003(HTTPS) 的 SignarR 服务。与原帖完全一样,当我手动运行 dll 时,它可以工作,但服务无法启动该进程,我猜是由于缺乏对端口 5002、5003 的权限。谢谢。

标签: ubuntu asp.net-core .net-core coredump systemctl


【解决方案1】:

根据此使用Downloads 文件夹来保存您的dll。下面配置.service文件

[Unit]
Description=MyService in .NET
# Requires=xyz.service
# After=xyz.service

[Service]
Type=simple
ExecStart=/usr/bin/dotnet  /home/linux/Downloads/MyService.dll

[Install]
WantedBy=multi-user.target

这条路径 /home/linux/Downloads/MyService.dll 在您的情况下可能会有所不同。

然后运行

sudo systemctl daemon-reload

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 2021-02-04
    • 2018-02-26
    • 2021-07-09
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    相关资源
    最近更新 更多