单元服务未正确加载:执行格式错误.在ubuntu18.04上创建.net服务 [英] Unit service is not loaded properly: Exec format error. on ubuntu18.04 creating .net service
问题描述
我正在尝试创建一个由ubuntu 18.04上的.net应用程序运行的服务.
I am trying to create a service to run by .net application on ubuntu 18.04.
cd/lib/systemd/system/YellowPages.service
cd /lib/systemd/system/YellowPages.service
[Unit]
Description = Yellow pages .NET service
[Service]
Type=forking
WorkingDirectory=/home/yp_app
ExecStart=dotnet /home/yp_app/YellowPages.dll
[Install]
WantedBy=multi-user.target
~
我的应用程序位于/home/yp_app.
I have my application on /home/yp_app.
当我运行时:systemd启动YellowPages.service 我懂了 多余的参数.
when I run:systemd start YellowPages.service I get Excess arguments.
所以我尝试了:systemctl start YellowPages.service 我知道了
so I tried with: systemctl start YellowPages.service I get
Failed to start YellowPages.service: Unit YellowPages.service is not loaded properly: Exec format error.
See system logs and 'systemctl status YellowPages.service' for details.
当我查看cat/var/log/syslog
When I look into cat /var/log/syslog
我可以看到
systemd[1]: /lib/systemd/system/YellowPages.service:7: Executable path is not
absolute: dotnet /home/yp_app/YellowPages.dll
我是Linux新手,我想知道哪里错了. 有人可以帮我吗?
I am new to Linux I am wondering where I am wrong. Could anyone help me with this?
推荐答案
守护程序存在两个问题:
There are a couple of issues with your daemon:
[Unit]
Description = Yellow pages .NET service
删除等号周围的空格:
[Unit]
Description=Yellow pages .NET service
ExecStart
需要绝对路径(因此会出现错误):
ExecStart
needs an absolute path (hence the error):
[Service]
Type=forking
WorkingDirectory=/home
ExecStart=/usr/bin/dotnet /home/yp_app/YellowPages.dll
您的dotnet
可执行文件可能位于其他位置,尽管您可以通过以下操作找到其绝对路径:
Your dotnet
executable might be located elsewhere, although you can find out its absolute path by doing:
$ which dotnet
返回的任何内容都是要使用的绝对路径.
Whatever is returned would be the absolute path to use.
这篇关于单元服务未正确加载:执行格式错误.在ubuntu18.04上创建.net服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!