Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Service File D-Bus

Tags:

dbus

I'm trying to auto-start a DBus service when my client program starts. I've setup a .service file, but it's not working.

My service name is

org.fandingo.PMP

I register the name with a python server with

 name = dbus.service.BusName('org.fandingo.PMP', session_bus)
 object = PMPService(session_bus, '/PMPService', PMPProxy())

I can connect to this fine if I manually run the server code with the following from the client

remote = bus.get_object('org.fandingo.PMP', '/PMPService')

So the server and client both work if invoked manually. If I just try the client, I get the following Python exception

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.fandingo.PMP was not provided by any .service files

Here is my .service file

-rw-r--r--. root root unconfined_u:object_r:usr_t:s0   /usr/share/dbus-1/services/org.fandingo.PMP.service

These permissions and SELinux labels are identical to the other .service files.

The .service file contents

[D-Bus Service]
Name=org.fandingo.PMP
Exec=/home/fandingo/code/python/pmp/src/pmpserver.py
User=fandingo

pmpserver.py is executable and has the correct shebang.

Does anyone see any problems with me configuration?

Thanks,

like image 847
fandingo Avatar asked Nov 13 '22 15:11

fandingo


1 Answers

Finally figured this one out.

I'm not sure exactly how .service files are executed, but they don't get /bin/env set properly.

My shebang was not working properly:

#!/usr/bin/env python

I changed my service file to

[D-Bus Service]
Name=org.fandingo.PMP
Exec=python /home/fandingo/code/python/pmp/src/pmpserver.py

Everything works great now.

like image 65
fandingo Avatar answered Dec 29 '22 00:12

fandingo