Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Ubuntu DBus and Upstart - Service controller
Forum Updated to NodeBB v4.3 + New Features

Ubuntu DBus and Upstart - Service controller

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rootshell
    wrote on 15 Apr 2014, 17:18 last edited by
    #1

    Hello,

    Been working on a large project that uses QService to create a service. One of the applications I want the abilty to control the service via the local system API. For example on windows I will use the Service Controller API, i have some working code out on my site, "Void Realms Source Code":http://voidrealms.com/index.php?r=source/view&id=22

    But my question here is specifically with upstart on Ubuntu. Upstart has a DBus interface which is fairly new to me:
    "Upstart DBus":http://upstart.ubuntu.com/wiki/DBusInterface

    I did find an example, but for the life of me I cant get it to work - error arguments are incorrect:
    "DBus example with Upstart":https://gitorious.org/chakra/kcm-systemd/source/706ef9bdbbca3172d478d53a568d1f8321a95b95:tests/trainingtests.cpp

    Can anyone point me in the right direction or show me a working example of how to query Upstart via DBus? Ideally I would like to be able to start / stop and query the service state.

    Thanks!

    [Update]
    Thought i had this solved but found I am still a long ways off...so far the only thing I can get working is getting a list of job paths from the Upstart dbus interface.

    Working code is:

    Pro file:
    qt += dbus

    Code file:

    @void test::performTest()
    {
    QDBusInterface interface(
    QLatin1String("com.ubuntu.Upstart"),
    QLatin1String("/com/ubuntu/Upstart"),
    QLatin1String("com.ubuntu.Upstart0_6"),
    QDBusConnection::systemBus()
    );

    qDebug() << "Getting all jobs";
    
    QDBusReply< QList<QDBusObjectPath> > reply = interface.call("GetAllJobs");
    if(reply.isValid())
    {
        foreach(QDBusObjectPath obj, reply.value())
        {
            qDebug() << "PATH = " << obj.path() << "\r\n";
        }
    }
    else
    {
        qDebug() << reply.error();
    }
    

    }@

    Even after reviewing the documentation I am still a bit lost - anyone have any experience controlling upstart jobs via DBus or should I just fire off a QProcess and read the output of initctl?

    Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

    Languages: C++, C#, VB, Python, Java

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rootshell
      wrote on 18 Apr 2014, 20:17 last edited by
      #2

      bump -

      Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

      Languages: C++, C#, VB, Python, Java

      1 Reply Last reply
      0

      1/2

      15 Apr 2014, 17:18

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved