Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Upstart Class Reference

Wrapper for the upstart-dbus-bridge interface that allows starting and stopping system services. More...

#include <Upstart.h>

Public Member Functions

 Upstart (const std::shared_ptr< AI_IPC::IIpcService > &ipcService)
 
bool start (const std::string &name, const std::vector< std::string > &env=std::vector< std::string >(), bool wait=true) const
 Attempts to start the service with the given name.
 
bool restart (const std::string &name, const std::vector< std::string > &env=std::vector< std::string >(), bool wait=true) const
 Attempts to perform a stop and a start on the service with the given name.
 
bool stop (const std::string &name, bool wait=true) const
 Attempts to stop the service with the given name.
 

Private Member Functions

bool invokeMethod (const std::string &method, const std::string &name, const std::vector< std::string > &env, bool wait) const
 Requests a start or a restart of a service.
 

Private Attributes

const std::shared_ptr< AI_IPC::IIpcService > & mIpcService
 
const std::string mService
 
const std::string mInterface
 

Detailed Description

Wrapper for the upstart-dbus-bridge interface that allows starting and stopping system services.

Upstart is the init process of the system, it is responsible for starting things like mesh, the system dbus and others. It is an open source project run by ubuntu; http://upstart.ubuntu.com/.

This class is just a wrapper around it's dbus interface, the best documentation on the interface I found is here: https://github.com/bernd/ruby-upstart/blob/master/UPSTART-DBUS.md

Warning
At the time of writing we are only allowed to start a single service ('skyDobbyDaemon'), this is due to the deliberately restrictive dbus policy as specified at the following location on the STB
/DBUS/etc/dbus-1/system.d/Upstart.conf

Member Function Documentation

◆ invokeMethod()

bool Upstart::invokeMethod ( const std::string &  method,
const std::string &  name,
const std::vector< std::string > &  env,
bool  wait 
) const
private

Requests a start or a restart of a service.

Since the Start and Restart methods are near identical in the way they are called over dbus, this function performs either based on the method argument.

Parameters
[in]methodThe method, should be either 'Start', 'Restart' or 'Stop'.
[in]nameThe name of the service to start.
[in]envAny extra environment variables to pass to the service being started
[in]waitWaits till the service is running before returning.
Returns
true if the service was started, otherwise false.

◆ restart()

bool Upstart::restart ( const std::string &  name,
const std::vector< std::string > &  env = std::vector<std::string>(),
bool  wait = true 
) const

Attempts to perform a stop and a start on the service with the given name.

This issues the a Restart command on the dbus interface for the service with the given name. The equivalent on the command line would look like this:

dbus-send \
    --system \
    --print-reply \
    --dest=com.ubuntu.Upstart \
    /com/ubuntu/Upstart/jobs/<name> \
    com.ubuntu.Upstart0_6.Job.Restart \
    array:string:<env> boolean:<wait>

Note this function will return an error if the service wasn't running prior to the call.

Parameters
[in]nameThe name of the service to restart.
[in]envAny extra environment variables to pass to the service being restarted
[in]waitWaits till the service is running before returning.
Returns
true if the service was restarted, otherwise false.

◆ start()

bool Upstart::start ( const std::string &  name,
const std::vector< std::string > &  env = std::vector<std::string>(),
bool  wait = true 
) const

Attempts to start the service with the given name.

This issues the a Start command on the dbus interface for the service with the given name. The equivalent on the command line would look like this:

dbus-send \
    --system \
    --print-reply \
    --dest=com.ubuntu.Upstart \
    /com/ubuntu/Upstart/jobs/<name> \
    com.ubuntu.Upstart0_6.Job.Start \
    array:string:<env> boolean:<wait>
Parameters
[in]nameThe name of the service to start.
[in]envAny extra environment variables to pass to the service being started
[in]waitWaits till the service is running before returning.
Returns
true if the service was started, otherwise false.

◆ stop()

bool Upstart::stop ( const std::string &  name,
bool  wait = true 
) const

Attempts to stop the service with the given name.

This issues the a Stop command on the dbus interface for the service with the given name. The equivalent on the command line would look like this:

dbus-send \
    --system \
    --print-reply \
    --dest=com.ubuntu.Upstart \
    /com/ubuntu/Upstart/jobs/<name> \
    com.ubuntu.Upstart0_6.Job.Stop \
    array:string:'' boolean:<wait>
Parameters
[in]nameThe name of the service to stop.
[in]waitWaits till the service is stopped before returning.
Returns
true if the service was stopped, otherwise false.

The documentation for this class was generated from the following files: