尝试使用 C# 应用程序运行服务
[Unit]
Description=TgBot1
[Service]
WorkingDirectory=/var/www/TgBot1
ExecStart=/usr/bin/dotnet /var/www/TgBot1/TgBotGetRequest
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
[Install]
WantedBy=multi-user.target
我收到一个错误
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: System.UnauthorizedAccessException: Access to the path '/var/www/.dotnet' is denied.
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: ---> System.IO.IOException: Permission denied
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: --- End of inner exception stack trace ---
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at System.IO.FileSystem.CreateDirectory(String fullPath, UnixFileMode unixCreateMode)
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at System.IO.Directory.CreateDirectory(String path)
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at Microsoft.Extensions.EnvironmentAbstractions.DirectoryWrapper.CreateDirectory(String path)
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at Microsoft.DotNet.Configurer.FileSystemExtensions.<>c__DisplayClass0_0.<CreateIfNotExists>b__0()
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at Microsoft.DotNet.Cli.Utils.FileAccessRetrier.RetryOnIOException(Action action)
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
Jan 09 20:34:06 racknerd-046249 dotnet-example[4851]: at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileS>
应用程序无法启动,并立即提示错误发生在 /var/www/.dotnet 的某个地方,我没有这样的文件夹。
我认为我以某种方式错误地启动了TgBotGetRequest
文件本身
。问题是什么?