centos 8 下設(shè)置.net core項目開機(jī)自動啟動
1.1在/etc/systemd/system 下創(chuàng)建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.立即啟動項目服務(wù)
systemctl start pgsqlcodefirst.service
systemctl stop pgsqlcodefirst.service
systemctl restart pgsqlcodefirst.service
systemctl list-units --type=service
5.重啟服務(wù):
shutdown -r now
6.重啟后訪問:http://ip:port/