1

I have an ASP.NET Core Angular application targeting dotnet 1.1.0.

I installed Nginx on my Linux Ubuntu 16.04 and configured the nginx confog file as follows:

server {
listen 80;
location / {
    proxy_pass http://localhost:5000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection keep-alive;
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
}

and myapp.services file as follows:

[Unit]
Description=Sample application.

[Service]

Type=simple
WorkingDirectory=/var/myappfolder
ExecStart=/usr/bin/dotnet /var/myappfolder/myapp.dll
#User=web

[Install]

WantedBy=multi-user.target

I tested this set up with a simple sample app and it worked fine. However as soon as I deploy my proper app to /var/myappfolder and configure

systemclt start mywebsite
systemclt daemon_reload

and then check

systemclt status mywebsite

I get this error:

jtrade.service - Sample application. Loaded: loaded (/lib/systemd/system/jtrade.service; disabled; vendor preset: enabled) Active: failed (Result: signal) since Wed 2017-08-30 18:08:08 UTC; 9s ago Process: 4640 ExecStart=/usr/bin/dotnet /var/jtrade/jtradep.dll (code=killed, signal=ABRT) Main PID: 4640 (code=killed, signal=ABRT)

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Configurer.NuGetCacheSentinel.get_NuGetCachePath()

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Configurer.NuGetCacheSentinel.Exists()

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.ShouldPrimeNugetCache()

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)

Aug 30 18:08:08 localhost dotnet[4640]: at Microsoft.DotNet.Cli.Program.Main(String[] args)

Aug 30 18:08:08 localhost systemd[1]: jtrade.service: Main process exited, code=killed, status=6/ABRT

Aug 30 18:08:08 localhost systemd[1]: jtrade.service: Unit entered failed state.

Aug 30 18:08:08 localhost systemd[1]: jtrade.service: Failed with result 'signal'.

So I dived deeper into debugging this error with journalctl -u myappname and got some more useful info:

Started Sample application..

Aug 31 05:13:34 localhost dotnet[10290]: Unhandled Exception: System.InvalidOperationException: Required environment variable 'HOME' is not set. Try setting 'HOME' and running the operation again.

Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Common.NuGetEnvironment.GetValueOrThrowMissingEnvVar(Func`1 getValue, String name)

Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Common.NuGetEnvironment.GetHome() Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Common.NuGetEnvironment.<>c.<.cctor>b__12_0()

Aug 31 05:13:34 localhost dotnet[10290]: at System.Lazy`1.CreateValue()

Aug 31 05:13:34 localhost dotnet[10290]: --- End of stack trace from previous location where exception was thrown ---

Aug 31 05:13:34 localhost dotnet[10290]: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Aug 31 05:13:34 localhost dotnet[10290]: at System.Lazy`1.get_Value()

Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Common.NuGetEnvironment.GetFolderPath(SpecialFolder folder)

Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder)

Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Configuration.SettingsUtility.GetGlobalPackagesFolder(ISettings settings)

Aug 31 05:13:34 localhost dotnet[10290]: at NuGet.Configuration.NuGetPathContext.Create(ISettings settings)

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Configurer.NuGetCacheSentinel.get_NuGetCachePath()

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Configurer.NuGetCacheSentinel.Exists()

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.ShouldPrimeNugetCache()

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)

Aug 31 05:13:34 localhost dotnet[10290]: at Microsoft.DotNet.Cli.Program.Main(String[] args)

Aug 31 05:13:34 localhost systemd[1]: jtrade.service: Main process exited, code=killed, status=6/ABRT

Aug 31 05:13:34 localhost systemd[1]: jtrade.service: Unit entered failed state.

Aug 31 05:13:34 localhost systemd[1]: jtrade.service: Failed with result 'signal'.

From here if I run to see my environment variables with printenv, I find that HOME= /root

Maybe it should be set to something else?

2
  • Just a quick note, after I publish the app using dotnet publish on my local machine I check the myapp.dll and run it with dotnet myapp.dll and it runs fine. Commented Aug 30, 2017 at 19:03
  • Also, on the server if I simply run the app with dotnet myapp.dll it also runs fine. So it is something to do with systemd configs I guess... Commented Aug 30, 2017 at 19:16

1 Answer 1

2

Apparently I just wrote Environment=HOME=/root in the .service file and everything started working

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.