在虚拟 Ubuntu 机器上将 asp.net core 应用程序设置为 systemd 服务时遇到问题

在虚拟 Ubuntu 机器上将 asp.net core 应用程序设置为 systemd 服务时遇到问题

的结果

$sudo systemctl status ascended.service

WARNING: terminal is not fully functional
● ascended.service - Ascended Guild main site dotnet core application
   Loaded: loaded (/etc/systemd/system/ascended.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2020-04-09 04:11:55 UTC; 6s ago
  Process: 5743 ExecStart=/usr/bin/dotnet /home/ascended/ascended/src/bin/Debug/netcoreapp3.1/linux-x64/AscendedGuild.dll (code=exited, status=200/CHDIR)
 Main PID: 5743 (code=exited, status=200/CHDIR)

Apr 09 04:11:55 aguild systemd[1]: ascended.service: Main process exited, code=exited, status=200/CHDIR
Apr 09 04:11:55 aguild systemd[1]: ascended.service: Failed with result 'exit-code'.

/etc/systemd/system/ascended.service

[Unit]
Description=Ascended Guild main site dotnet core application

[Service]
WorkingDirectory=/home/ascended/src/
ExecStart=/usr/bin/dotnet /home/ascended/ascended/src/bin/Debug/netcoreapp3.1/linux-x64/AscendedGuild.dll
Restart=always
RestartSec=30
SyslogIdentifier=ascended
User=ascended
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

dotnet /bin/Debug/netcoreapp3.1/linux-x64/AscendedGuild.dll当用户“升职”时从工作目录内执行即可正常运行应用程序。

根据我的研究,问题似乎出在工作目录的权限上。我尝试更改权限,但我对 chown 不太熟悉,错误仍然存​​在。

输出 ls -la home/ascended/ascended/

total 24
drwxrwsrwx  4 ascended www-data 4096 Mar 17 03:33 .
drwxr-xr-x 13 ascended ascended 4096 Apr  9 04:00 ..
drwxrwxr-x  8 ascended ascended 4096 Mar 17 03:33 .git
-rw-rw-r--  1 ascended ascended 6110 Mar 17 03:33 .gitignore
-rw-rw-r--  1 ascended ascended    0 Mar 17 03:33 README.md
drwxrwxr-x 12 ascended ascended 4096 Apr  9 03:38 src

相关内容