ASP.NET Core Angular应用程序无法在Nbux和Systemd

时间:2017-08-30 18:17:27

标签: .net linux ubuntu nginx core

我有一个针对dotnet 1.1.0的ASP.NET Core Angular应用程序。

我在Linux Ubuntu 16.04上安装了Nginx并配置了nginx confog文件,如下所示:

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;
}
}

和myapp.services文件如下:

[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

我用一个简单的示例应用程序测试了这个设置,它工作正常。但是,只要我将适当的应用程序部署到/ var / myappfolder并配置

systemclt start mywebsite
systemclt daemon_reload

然后检查

systemclt status mywebsite

我收到此错误。

jtrade.service - 示例应用程序。    已加载:已加载(/lib/systemd/system/jtrade.service;已禁用;供应商预设:已启用)    活动:自2017年3月30日星期三18:08:08 UTC以来失败(结果:信号); 9s ago   进程:4640 ExecStart = / usr / bin / dotnet /var/jtrade/jtradep.dll(code = killed,signal = ABRT)  主PID:4640(代码=已杀死,信号= 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:主进程退出,代码=已杀死,状态= 6 / ABRT

Aug 30 18:08:08 localhost systemd [1]:jtrade.service:Unit进入失败状态。

8月30日18:08:08 localhost systemd [1]:jtrade.service:结果'信号失败。

因此,我深入研究了使用journalctl -u myappname调试此错误,并获得了一些更有用的信息。

启动示例应用程序..

8月31日05:13:34 localhost dotnet [10290]:未处理的异常:System.InvalidOperationException:必需的环境变量' HOME'没有设定。尝试设置' HOME'并再次运行该操作。

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

Aug 31 05:13:34 localhost dotnet [10290]:在NuGet.Common.NuGetEnvironment.GetHome() 8月31日05:13:34 localhost dotnet [10290]:在NuGet.Common.NuGetEnvironment。<> c。< .cctor> b__12_0()

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

8月31日05:13:34 localhost dotnet [10290]:---从抛出异常的上一个位置开始的堆栈跟踪结束---

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]:在NuGet.Common.NuGetEnvironment.GetFolderPath(SpecialFolder文件夹)

Aug 31 05:13:34 localhost dotnet [10290]:在NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath文件夹)

Aug 31 05:13:34 localhost dotnet [10290]:在NuGet.Configuration.SettingsUtility.GetGlobalPackagesFolder(ISettings设置)

Aug 31 05:13:34 localhost dotnet [10290]:在NuGet.Configuration.NuGetPathContext.Create(ISettings设置)

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)

8月31日05:13:34 localhost dotnet [10290]:在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)

8月31日05:13:34 localhost systemd [1]:jtrade.service:主进程退出,代码=已杀死,状态= 6 / ABRT

8月31日05:13:34 localhost systemd [1]:jtrade.service:单位进入失败状态。

8月31日05:13:34 localhost systemd [1]:jtrade.service:结果'信号'失败。

从这里如果我用printenv运行查看我的环境变量,我发现HOME = / root

也许它应该设置为其他东西......

我不知道从哪里开始,对于任何线索,提示都会非常有用。谢谢。

1 个答案:

答案 0 :(得分:0)

显然我刚写了 环境= HOME = /根 在.service文件中,一切都开始工作