单元服务未正确加载:Exec 格式错误.在 ubuntu18.04 上创建 .net 服务 [英] Unit service is not loaded properly: Exec format error. on ubuntu18.04 creating .net service

查看:88
本文介绍了单元服务未正确加载:Exec 格式错误.在 ubuntu18.04 上创建 .net 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个服务以在 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.

这篇关于单元服务未正确加载:Exec 格式错误.在 ubuntu18.04 上创建 .net 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆