Application crashes as a service but runs without issues manually

3 个月 前
I have deployed and nopCommerce v4.60.5 to my Debian 11 server for testing.
When I start the service to handle the application state I get a following error:

root@localhost:/var/www# sudo systemctl status nopCommerce.service
● nopCommerce.service - Example nopCommerce app running on Debian
     Loaded: loaded (/etc/systemd/system/nopCommerce.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-01-30 11:29:59 UTC; 6s ago
   Main PID: 20375 (dotnet)
      Tasks: 15 (limit: 1115)
     Memory: 276.9M
        CPU: 5.813s
     CGroup: /system.slice/nopCommerce.service
             └─20375 /usr/bin/dotnet /var/www/nopCommerce/Nop.Web.dll

Jan 30 11:29:59 localhost systemd[1]: Started Example nopCommerce app running on Debian.
Jan 30 11:30:03 localhost dotnet[20375]: Nop.Web Error: 0 :
Jan 30 11:30:03 localhost dotnet[20375]: System.IO.FileLoadException: Could not load file or assembly 'System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
                                            at System.Runtime.Loader.AssemblyLoadContext.<LoadFromPath>g____PInvoke|5_0(IntPtr ptrNativeAssemblyBinder, UInt16* ilPath, UInt16* niPath, ObjectHan>
                                            at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
                                            at System.Reflection.Assembly.LoadFrom(String assemblyFile)
                                            at Nop.Core.Infrastructure.NopEngine.AssemblyResolver.GetAssemblyByFullName(String assemblyFullName)


If I manually start the application it runs without issues.
Here is a snippet.

root@localhost:/var/www/nopCommerce# sudo systemctl stop nopCommerce.service
root@localhost:/var/www/nopCommerce# dotnet Nop.Web.dll
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /var/www/nopCommerce
info: System.Net.Http.HttpClient.default.LogicalHandler[100]

I verified the permissions, and tried reinstalling service but didn't get anywhere.
Please advise.
3 个月 前
Hi, could you tell me the specifications of your RAM server?
3 个月 前
Would you post here the content of you /etc/systemd/system/nopCommerce.service file.

Also do this command and post info here.
dotnet --info
3 个月 前
bhanuchauhan wrote:
Hi, could you tell me the specifications of your RAM server?

Linode shared server. 1GB RAM, single CPU, 25GB Storage.

New York wrote:
Would you post here the content of you /etc/systemd/system/nopCommerce.service file.

Also do this command and post info here.
dotnet --info

It's the same as from installation instructions.

[Unit]
Description=Example nopCommerce app running on Debian

[Service]
WorkingDirectory=/var/www/nopCommerce
ExecStart=/usr/bin/dotnet /var/www/nopCommerce/Nop.Web.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=nopCommerce-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target


root@localhost:~# dotnet --info

Host:
  Version:      7.0.15
  Architecture: x64
  Commit:       8f4568cdaa

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.15 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.15 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download








3 天 前
Hi. This problem was described earlier and has already been fixed in the minor release 4.60.6. In short, for some reason in some environments, the .net core stopped finding some assemblies, we solved this problem by loading such assemblies ourselves.