title: how to run a .net core web API as Linux daemon
body: <p>i have created a .net core web API then add the flowing package
  Microsoft.AspNetCore.Hosting.WindowsServices;
  to my <code>program.cs</code>
  then write the flowing code in <code>program.cs</code></p>
  
  <p><a href="https://i.stack.imgur.com/Be48R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Be48R.png" alt="enter image description here"></a></p>
  
  <p>then copy the whole project to Linux Ubuntu and published it with the flowing command</p>
  
  <p><code>dotnet publish -c release -r ubuntu.16.04-x64</code></p>
  
  <p>then copied the created publish folder to :  <code>/etc/SampleWebservice</code></p>
  
  <p>and copy the .dll file to  :     <code>/usr/share/dotnet</code> </p>
  
  <p>and create the <code>.service</code> file like this</p>
  
  <pre><code>     [Unit]  
       Description=Dotnet Core WebApi Demo service  
  
       [Service]  
       ExecStart=/usr/share/dotnet/weba.dll  
       WorkingDirectory=/etc/SampleWebservice/publish/  
       User=dotnetuser  
       Group=dotnetuser  
       Restart=on-failure  
       SyslogIdentifier=dotnet-webapi-service  
       PrivateTemp=true  
  
      [Install]  
      WantedBy=multi-user.target
  </code></pre>
  
  <p>then run these commands</p>
  
  <pre><code>Sudu systemctl daemon-reload
  Sudo systemctl enable servicename
  Sudo systemctl start servicename
  Sudo systemctl status servicename
  </code></pre>
  
  <p>and i got the flowing status
  <a href="https://i.stack.imgur.com/08rkD.png" rel="nofollow noreferrer">daemon status</a></p>
  
  <p>it works fine on windows and install as a windows service and everything is OK but does not work on Linux.
  can anyone tell me what i have done wrong?
  is it from the packages or the config code in <code>program.cs</code>
  or is it the <code>.service</code> file.
  i am really stuck and i will appreciate your help.</p>