2017-08-30 49 views
0

我有一个针对dotnet 1.1.0的ASP.NET Core Angular应用程序。ASP.NET Core Angular应用程序无法在使用Nginx和Systemd的Ubuntu 16.04上运行

我在我的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-08-30 18:08:08 UTC; 787-9前 过程:4640 ExecStart =的/ usr /斌/ DOTNET /var/jtrade/jtradep.dll(代码=杀死,信号= ABRT) 主PID:4640(代码=杀死,信号= ABRT)

八月30 18点08分08秒的dotnet本地主机[4640]:在Microsoft.DotNet.Configurer.NuGetCacheSentinel.get_NuGetCachePath()

年08月30 18点08分08秒的dotnet本地主机[4640]:在Microsoft.DotNet.Configurer.NuGetCacheSentinel。存在()

年08月30 18点08分08秒的dotnet本地主机[4640]:在Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.ShouldPrimeNugetCache()

在Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()

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

年08月30 18点08分08秒的dotnet本地主机[4640]:在Microsoft.DotNet.Cli.Program.ProcessArgs(字串[] args,ITelemetry telemetryClient)

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

Aug 30 18:08 :08本地主机systemd [1]:jtrade.service:主进程退出,代码=杀死,状态= 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:结果'signal'失败。


因此,我深入调试了这个错误与journalctl -u myappname并得到了一些更有用的信息。


开始示例应用程序..

Aug 31 05:13:34 localhost dotnet [10290]:未处理的异常:System.InvalidOperationException:未设置必需的环境变量'HOME'。尝试设置“家”,并再次运行操作。

年08月31 5点13分34秒的dotnet本地主机[10290]:在NuGet.Common.NuGetEnvironment.GetValueOrThrowMissingEnvVar(Func`1的getValue,字符串名称)

年08月31 5点13分34秒的dotnet本地主机[10290] :在NuGet.Common.NuGetEnvironment.GetHome() 年08月31 5时13分34秒的dotnet本地主机[10290]:在NuGet.Common.NuGetEnvironment。 <> c。 < .cctor> b__12_0()

年08月31 5时13分34秒的dotnet本地主机[10290]:在System.Lazy`1.CreateValue()

年08月31 5时13分34秒的dotnet本地主机[10290] :---从先前位置栈跟踪其中抛出异常---

年08月31 5时十三分34秒的dotnet本地主机[10290]的结束:在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

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

年08月31 5时13分34秒的dotnet本地主机[10290]:在NuGet.Common.NuGetEnvironment.GetFolderPath(SpecialFolder文件夹)

年08月31 5时13分34秒的dotnet本地主机[10290]:在NuGet.Common.NuGetEnvironment。 GetFolderPath(NuGetFolderPath文件夹)

年08月31 5时13分34秒的dotnet本地主机[10290]:在NuGet.Configuration.SettingsUtility.GetGlobalPackagesFolder(ISettings设置)

年08月31 5时13分34秒的dotnet本地主机[10290] :在NuGet.Configuration.NuGetPathContext.Create(设置设置)

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

年08月31 5时13分34秒的dotnet本地主机[10290]:在Microsoft.DotNet.Configurer.NuGetCacheSentinel.Exists()

05年8月31日:13:34本地主机的dotnet [10290]:在Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.ShouldPrimeNugetCache()

年08月31 5点13分34秒的dotnet本地主机[10290]:在Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure( )

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

年08月31 5时13分34秒的dotnet本地主机[10290]:在Microsoft.DotNet.Cli.Program.ProcessArgs(字串[] args,ITelemetry telemetryClient)

年08月31 5点13分:34 localhost dotnet [10290]:at Microsoft.DotNet.Cli.Program.Main(String [] args)

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

Aug 31 05:13:34 localhost systemd [1]:jtrade.service:单元进入失败状态。

Aug 31 05:13:34 localhost systemd [1]:jtrade.service:结果'signal'失败。


从这里,如果我跑,看看我的环境变量与printenv,我发现HOME = /根

也许它应该被设置为别的东西......

我不知道哪里可以从这里出发,并且对于任何线索和暗示都是真正的伟大。谢谢。

+0

只是一个快速的注意,我用的dotnet我的本地机器上发布我检查MYAPP发布应用程序之后。 DLL和运行它与dotnet myapp.dll,它运行良好。 –

+0

另外,在服务器上,如果我只是用dotnet myapp.dll运行应用程序,它也能正常运行。所以这是与systemd配置我想猜... –

回答

0

显然,我只是写 环境= HOME = /根 的。服务文件,一切都开始工作

相关问题