0

I have to run my application as service in ubuntu 16.04. I am using systemd to make it run as service during bootup time. My application has to connect to both session dbus and system dbus. connecting to system dbus is successful. But connecting to session dbus is failing. I tried to run my application as service using "systemctl start Myapplication", this time also it is not connecting to session bus. But if I run my application from terminal by "./Myapplication" , it is successfully connecting to both session and and system dbus. can anyone help me with this?

The below code is my .service file content.


[Unit]

Description=node-health-monitor to observe system health

[Service]

Type=notify

ExecStart=/home/deepan/deepan/Myapplication

[Install]

WantedBy=graphical.target

Iam using GDBUS.

Thomas
  • 1,445
  • 14
  • 30
deepan muthusamy
  • 321
  • 2
  • 14
  • It is not clear what the error or problem is. Perhaps you should reduce things to a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Be sure to include your D-Bus code. – jww Jun 28 '18 at 06:23

1 Answers1

0

Set it up as user-service (so it can be run as systemctl --user start Myapplication).

Or keep using it as a system-wide service, but somehow switch the user in Myapplication when connecting to the session bus.


What I think causes problems:

The Myapplication is run as root user when doing systemctl start Myapplication.

So when it tries to connect to the session bus, it's trying to connect to the session of the root user.

Velkan
  • 7,067
  • 6
  • 43
  • 87
  • Actually I want to connect to session bus of the root only. In the post i mentioned "./MyApplication", but i executed the command as root user only. Iam not clear why it is not connecting to the root session bus. can you please clarify this to me. – deepan muthusamy Jul 06 '18 at 06:23