2020-12-18 乐帮网
centos netcore
遇到场景,在CentOS中使用NetCore3.1写了一个服务类,然后在目录/usr/lib/systemd/system下配置vktdemo.service文件,再使用systemctl start vktdemo启动服务,遇到如下错误:
-- Automatic restarting of the unit vktdemo.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Dec 18 01:44:11 test systemd[1]: Stopped vkt demo service.
-- Subject: Unit vktdemo.service has finished shutting down
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit vktdemo.service has finished shutting down.
Dec 18 01:44:11 test systemd[1]: Starting vkt demo service...
-- Subject: Unit vktdemo.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit vktdemo.service has begun starting up.
Dec 18 01:44:11 test systemd[43405]: vktdemo.service: Failed to execute command: Exec format error
Dec 18 01:44:11 test systemd[43405]: vktdemo.service: Failed at step EXEC spawning /home/vktservice/demo/vkt.demo.workerservice.dll: Exec format error
-- Subject: Process /home/vktservice/demo/vkt.demo.workerservice.dll could not be executed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The process /home/vktservice/demo/vkt.demo.workerservice.dll could not be executed and failed.
--
-- The error number returned by this process is 8.
Dec 18 01:44:11 test systemd[1]: vktdemo.service: Main process exited, code=exited, status=203/EXEC
Dec 18 01:44:11 test systemd[1]: vktdemo.service: Failed with result 'exit-code'.
Dec 18 01:44:11 test systemd[1]: Failed to start vkt demo service.
-- Subject: Unit vktdemo.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit vktdemo.service has failed.
--
-- The result is failed.
经过分析,问题出在执行入口的地方,从以下两方面解决问题,
(1)检查入口文件的路径是否正确。
(2)服务入口文件的命令行不正确。
我这个是由于填写的入口命令行不正确,由于我是netCore发布的服务,执行入口写成了ExecStart=/home/vktservice/demo/vkt.demo.workerservice.dll
正确的写法是:ExecStart=/usr/bin/dotnet /home/vktservice/demo/vkt.demo.workerservice.dll
重新修改文件后重新启动服务,一切都正常了。
部署过程详情:https://lebang2020.cn/details/201217nfitaj1o.html
相关链接:https://lebang2020.cn/details/201218xz1dniwx.html
相关链接:https://lebang2020.cn/details/201217xfuwvsjn.html
本文地址:https://lebang2020.cn/details/2012181wvtl3ns.html
原创禁止转载!
关注我的微信公众号
在公众号里留言交流
投稿邮箱:1052839972@qq.com
庭院深深深几许?杨柳堆烟,帘幕无重数。
玉勒雕鞍游冶处,楼高不见章台路。
雨横风狂三月暮。门掩黄昏,无计留春住。
泪眼问花花不语,乱红飞过秋千去。
如果感觉对您有帮助
欢迎向作者提供捐赠
这将是创作的最大动力