Linux(Debian)下部署.NET Core网站(守护进程)
守护进程(可选)
sudo nano /etc/systemd/system/opac.service
键入文本
[Unit] Description=opac OPAC [Service] WorkingDirectory=/usr/share/opac ExecStart=/usr/bin/dotnet /usr/share/opac/OPAC.dll --urls=http://192.168.0.121:8001 & Restart=always # Restart service after 10 seconds if the dotnet service crashes RestartSec=10 SyslogIdentifier=OPAC Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install] WantedBy=multi-user.target
将Core项目放到/usr/share/opac文件夹下
启动并启用服务:最后,启动你的服务,并设置它在系统启动时自动启动。
sudo systemctl start opac.service
sudo systemctl enable opac.service
查服务状态:你可以使用以下命令来检查你的服务状态。
sudo systemctl status opac.service