Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
添加到Linux(ARM)deamon的.NET CORE 2.1应用程序导致CPU高_Linux_Raspberry Pi_.net Core_Debian - Fatal编程技术网

添加到Linux(ARM)deamon的.NET CORE 2.1应用程序导致CPU高

添加到Linux(ARM)deamon的.NET CORE 2.1应用程序导致CPU高,linux,raspberry-pi,.net-core,debian,Linux,Raspberry Pi,.net Core,Debian,我使用的是Linux ARM IOT板操作系统,我的控制台应用程序是在.NET CORE 2.1上开发的 我的应用程序非常简单,只需打开几个到远程服务器的TCP连接,在构建我的应用程序(使用symbolLinux ARM)后,我可以看到输出文件包括myApp,和myApp.dll。我已经通过命令行直接运行了很多次: pi@raspberrypi:~/Desktop/myApp $ ./myApp 或: 运行良好,通过top(进程名为myApp,而后者为dotnet)的CPU均小于20 今天,我

我使用的是Linux ARM IOT板操作系统,我的控制台应用程序是在.NET CORE 2.1上开发的

我的应用程序非常简单,只需打开几个到远程服务器的TCP连接,在构建我的应用程序(使用symbol
Linux ARM
)后,我可以看到输出文件包括
myApp
,和
myApp.dll
。我已经通过命令行直接运行了很多次:

pi@raspberrypi:~/Desktop/myApp $ ./myApp
或:

运行良好,通过
top
(进程名为
myApp
,而后者为
dotnet
)的CPU均小于20

今天,我想将我的应用程序添加到守护进程,以便一直运行,这是我的守护进程服务文件,位于
/etc/systemd/system
下:

[Unit]
Description=myApp for controlling Tcp devices

[Service]
WorkingDirectory=/home/pi/Desktop/myApp
# 
ExecStart=/usr/local/bin/dotnet myApp.dll
Restart=always
# Restart service after 10 seconds if this service crashes:
RestartSec=10
SyslogIdentifier=myApp
# User=pi
[Install]
WantedBy=multi-user.target
启用
后,通过
systemctl
命令启动
服务,我可以看到应用程序正在通过
top
运行(进程名为
dotnet
),但现在CPU相当高(对于进程
dotnet
),超过100


你知道CPU是如何上升的吗?有没有办法保留我的进程名而不是
dotnet

最后我发现原因是
Main
中的代码:

static void Main(string[] args)
{
    //my business logic code
    //balabala
    while (true)
       Console.ReadLine();
}

这意味着在deamon模式下,
Console.ReadLine()
总是可以读取一个空间并导致无限循环,这会消耗CPU,我不知道这个空间是怎么来的,这是.NET CORE的错误吗?

64位ARM对.NET CORE的支持仍然是实验性的。您可以通过适当的GitHub repo向Microsoft报告此类问题。尽管.NET内核可能仍然不太稳定,但是直接运行
和通过守护进程运行
之间有什么区别,这导致同一个应用程序的行为不同。你能给我看看你提到的链接吗?
。NET CORE for linux ARM仍然是实验性的
?ARM32从.NET CORE 2.1开始就得到了全面支持,就在几个月前,@LexLi我使用的是
linux(armhf)
,我们在这里提到了
linux ARM32
,请参阅此处的.NET核心运行时:Pi3B+具有64位CPU,但我相信Raspian仅支持ARM 32。
static void Main(string[] args)
{
    //my business logic code
    //balabala
    while (true)
       Console.ReadLine();
}