centos 7 下设置.net core项目开机自启动
1.1在/etc/systemd/system 下创建xxx.service文件;如:myoacore.service
1.2myoacore.service文件添加:
[Unit]
Description="oa service"
[Service]
Type=simple
GuessMainPID=true
WorkingDirectory=/www/core/
StandardOutput=journal
StandardError=journal
ExecStart=/usr/bin/dotnet oa.dll
Restart=always
[Install]
WantedBy=multi-user.target
2.使自启动生效
systemctl enable myoacore.service
3.立即启动项目服务
systemctl start myoacore.service
4.查看服务状态:
systemctl status myoacore.service
5.重启服务:
shutdown -r now
6.重启后访问:http://ip:port/