centos 8 下设置.net core项目开机自动启动
1.1在/etc/systemd/system 下创建pgsqlcodefirst.service文件;
pgsqlcodefirst.service文件添加:
[Unit]
Description="pgsqlcodefirst.Service"
[Service]
Type=simple
GuessMainPID=true
WorkingDirectory=/home/net50/
StandardOutput=journal
StandardError=journal
ExecStart=/usr/lib64/dotnet/dotnet /home/net50/pgsqlcodefirst.dll //启动指令
Restart=always
[Install]
WantedBy=multi-user.target
2.使自启动生效
systemctl enable pgsqlcodefirst.service
3.立即启动项目服务
systemctl start pgsqlcodefirst.service
systemctl stop pgsqlcodefirst.service
systemctl restart pgsqlcodefirst.service
systemctl list-units --type=service
5.重启服务:
shutdown -r now
6.重启后访问:http://ip:port/