Linux DBus .service 文件丢失
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9191370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DBus .service file missing
提问by pss
I am building custom dbus
service for my own demands and want it to start automatically when someone need it. For that purpose I've created .service
file like this
我正在dbus
根据自己的需求构建定制服务,并希望它在有人需要时自动启动。为此,我创建了这样的.service
文件
[D-Bus Service]
Name=com.mycompany.servicename
Exec=/home/myuser/Workspace/service-start
User=myuser
Here I just changed the actual name of service and executable but this is not the point. I've double checked real names - it matches exactly.
I've placed this file under name com.mycompany.servicename.service to /usr/share/dbus-1/services folder (I am using Ubuntu 11.10)
Executable file has x
permissions for everyone.
And here is the problem - when I am trying to start client that performs
在这里,我只是更改了服务和可执行文件的实际名称,但这不是重点。我已经仔细检查过真实姓名 - 它完全匹配。我已将此文件以 com.mycompany.servicename.service 的名称放置到 /usr/share/dbus-1/services 文件夹(我使用的是 Ubuntu 11.10) 可执行文件x
对每个人都有权限。这就是问题所在 - 当我尝试启动执行
bus = dbus.SessionBus()
bus.get_object('com.mycompany.servicename','/path/to/object')
I get dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name com.mycompany.servicename was not provided by any .service files
我得到 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name com.mycompany.servicename was not provided by any .service files
Object with path '/path/to/object'
is registered right after service start.
I just don't get why dbus
can't find my .service
file. Maybe I am missing something? Any ideas?
'/path/to/object'
服务启动后立即注册带有路径的对象。我就是不明白为什么dbus
找不到我的.service
文件。也许我错过了什么?有任何想法吗?
EditI've managed to get D-BUS automatically start my script. The section of .service
file should be named [D-BUS Service]
instead of [D-Bus service]
编辑我设法让 D-BUS 自动启动我的脚本。.service
文件的部分应该被命名[D-BUS Service]
而不是[D-Bus service]
回答by mzuther
Here's a short summary of the comments...
这是评论的简短摘要...
Create the subdirectory dbus-1/services/
in one of the directories named in the XDG Base Directory Specification. Usually, ~/.local/share/dbus-1/services/
works just fine. Enter the new subdirectory, create a file called com.mycompany.servicename.service
and add the lines:
dbus-1/services/
在XDG 基本目录规范中指定的目录之一中创建子目录。通常,~/.local/share/dbus-1/services/
工作得很好。进入新的子目录,创建一个名为的文件com.mycompany.servicename.service
并添加以下行:
[D-BUS Service]
Name=com.mycompany.servicename
Exec=/home/myuser/Workspace/service-start
User=myuser
Please note that D-BUSin [D-BUS Service]
needs to be capitalized.
请注意,D-BUSin[D-BUS Service]
需要大写。
That's it!
就是这样!
回答by Prakhar Dev Gupta
This resolved the same problem for me:
这为我解决了同样的问题:
sudo apt-get install --reinstall dbus python-dbus python3-dbus