Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
1 of 2

Cannot execute dotnet app as daemon service

I'm trying to run my dotnet application as a daemon service, the first steps that I did are:

Created the application using NetCore 2.0
Build the binary using dotnet publish swp

inside Ubuntu terminal I created an user for run the daemon:

sudo useradd -s /sbin/nologin dotnetuser
sudo mkdir /var/swp
sudo cp -R /home/publish/* /var/swp
sudo chown -R dotnetuser:dotnetuser /var/swp

so I created a custom systemd unit file under: /etc/systemd/system/netcore-console-swp.service directory:

[Unit]
Description= Scraper SWP
DefaultDependencies = no

[Service]
Type = oneshot
RemainAfterExit = no
ExecStart= /var/bot/ swp.dll
WorkingDirectory = /var/swp
User = dotnetuser
Group = dotnetuser

[install]

I tried to execute the daemon using the systemctl status command: start netcore-console-swp.service

but I got:

netcoreconsole-swp.service: Main process exited, code=exit

if I execute the app as dotnet swp.dll this working, what is wrong in my configuration?

What I did wrong?