I'm using RaspberryPi (3B+) Linux ARM IOT board which OS is Debian Stretch 9, and my console application is developed on .NET CORE 2.1.
My application is quite simple by just open several TCP connections to a remote server, after build my application (with symbol Linux ARM
), I can see the output files include myApp
, and myApp.dll
. I've done lots of run via directly command line:
pi@raspberrypi:~/Desktop/myApp $ ./myApp
or:
pi@raspberrypi:~/Desktop/myApp $ dotnet ./myApp.dll
which both runs well, and the CPU via top
(process name is myApp
, while the latter is dotnet
) are all less than 20.
Today I want to add my app to daemon for keep runing all the way, this is my daemon serivce file under /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
after enable, start
the service via systemctl
command, I can see the app is running via top
(the process name is dotnet
), but now the CPU is quite high (for process dotnet
) which is over 100.
Any idea for how the CPU rises, and is there a way to keep my process name back rather than dotnet
?
Finally I found the cause is the code in
Main
:that means in deamon mode, the
Console.ReadLine()
always can read a space and cause an infinite loop, which consumed the CPU, I'm not sure how that space coming, is that .NET CORE bug?