The root Dobby object, runs the dbus loop.
More...
#include <Dobby.h>
|
enum | LogTarget : unsigned { Console = 0x1
, SysLog = 0x2
, EthanLog = 0x4
, Journald = 0x8
} |
|
|
| Dobby (const std::string &dbusAddress, const std::shared_ptr< AI_IPC::IIpcService > &ipcService, const std::shared_ptr< const IDobbySettings > &settings) |
|
void | run () const |
| Issues a 'ready' signal over dbus and then blocks until either a shutdown request is received or SIGTERM.
|
|
void | setDefaultAIDbusAddresses (const std::string &aiPrivateBusAddress, const std::string &aiPublicBusAddress) |
| Debugging function for manually setting the AI dbus addresses. More...
|
|
|
static void | configSignals () |
| Utility function that MUST be called at startup from the main thread before any other threads are spawned. More...
|
|
static void | setupLogging (unsigned targets=LogTarget::Console) |
| Static method must be called early in the startup before object is instantiated. More...
|
|
|
| DOBBY_DBUS_METHOD (ping) |
|
| DOBBY_DBUS_METHOD (shutdown) |
|
| DOBBY_DBUS_METHOD (setLogMethod) |
|
| DOBBY_DBUS_METHOD (setLogLevel) |
|
| DOBBY_DBUS_METHOD (setAIDbusAddress) |
|
| DOBBY_DBUS_METHOD (startFromSpec) |
|
| DOBBY_DBUS_METHOD (startFromBundle) |
|
| DOBBY_DBUS_METHOD (stop) |
|
| DOBBY_DBUS_METHOD (pause) |
|
| DOBBY_DBUS_METHOD (resume) |
|
| DOBBY_DBUS_METHOD (hibernate) |
|
| DOBBY_DBUS_METHOD (wakeup) |
|
| DOBBY_DBUS_METHOD (addMount) |
|
| DOBBY_DBUS_METHOD (removeMount) |
|
| DOBBY_DBUS_METHOD (exec) |
|
| DOBBY_DBUS_METHOD (list) |
|
| DOBBY_DBUS_METHOD (getState) |
|
| DOBBY_DBUS_METHOD (getInfo) |
|
| DOBBY_DBUS_METHOD (getOCIConfig) |
|
void | initIpcMethods () |
| Installs handlers for all the dbus/ipc methods.
|
|
void | onContainerStarted (int32_t cd, const ContainerId &id) |
| Called by the DobbyManager code when a container has started. More...
|
|
void | onContainerStopped (int32_t cd, const ContainerId &id, int status) |
| Called by the DobbyManager code when a container has stopped. More...
|
|
void | onContainerHibernated (int32_t cd, const ContainerId &id) |
| Called by the DobbyManager code when a container gets hibernated. More...
|
|
void | onContainerAwoken (int32_t cd, const ContainerId &id) |
| Called by the DobbyManager code when a container returns back from hibernated. More...
|
|
void | runWorkQueue () const |
| Runs the Dobby work queue to handle API calls.
|
|
|
static void | nullSigChildHandler (int sigNum, siginfo_t *info, void *context) |
| Signal handler that does nothing. More...
|
|
static void | sigTermHandler (int sigNum) |
| Signal handler for SIGTERM.
|
|
static void | logPrinter (int level, const char *file, const char *func, int line, const char *message) |
| Logging callback, called every time a log message needs to be emitted. More...
|
|
static void | logConsolePrinter (int level, const char *file, const char *func, int line, const char *message) |
| Writes logging output to the console. More...
|
|
|
std::shared_ptr< DobbyEnv > | mEnvironment |
|
std::shared_ptr< DobbyUtils > | mUtilities |
|
std::shared_ptr< DobbyIPCUtils > | mIPCUtilities |
|
std::shared_ptr< DobbyManager > | mManager |
|
std::unique_ptr< DobbyWorkQueue > | mWorkQueue |
|
const std::shared_ptr< AI_IPC::IIpcService > | mIpcService |
|
const std::string | mService |
|
const std::string | mObjectPath |
|
std::list< std::string > | mHandlers |
|
std::atomic< bool > | mShutdown |
|
int | mWatchdogTimerId |
|
|
static volatile sig_atomic_t | mSigTerm = 0 |
|
static std::atomic< unsigned > | mLogTargets |
| The target for logging, can be dynamically changed via dbus.
|
|
static int | mEthanLogPipeFd = -1 |
|
The root Dobby object, runs the dbus loop.
◆ configSignals()
void Dobby::configSignals |
( |
| ) |
|
|
static |
Utility function that MUST be called at startup from the main thread before any other threads are spawned.
This is needed to fix a bunch of quirks relating to how signals are handled, in particular the SIGCHLD signal.
◆ logConsolePrinter()
void Dobby::logConsolePrinter |
( |
int |
level, |
|
|
const char * |
file, |
|
|
const char * |
func, |
|
|
int |
line, |
|
|
const char * |
message |
|
) |
| |
|
staticprivate |
Writes logging output to the console.
This duplicates code in the Logging component, but unfortunately we can't use the function there without messing up the API for all other things that use it.
◆ logPrinter()
void Dobby::logPrinter |
( |
int |
level, |
|
|
const char * |
file, |
|
|
const char * |
func, |
|
|
int |
line, |
|
|
const char * |
message |
|
) |
| |
|
staticprivate |
Logging callback, called every time a log message needs to be emitted.
Depending on the log method, this will either send the message to syslog or the ethanlog library.
Note that this function is called after any processing in the Logger component, meaning that you can still print log messages on the console by using the AI_LOG_CHANNELS env var.
◆ nullSigChildHandler()
void Dobby::nullSigChildHandler |
( |
int |
sigNum, |
|
|
siginfo_t * |
info, |
|
|
void * |
context |
|
) |
| |
|
staticprivate |
Signal handler that does nothing.
This is needed to ensure SIGCHLD signals are actually delivered and detected by sigwaitinfo
◆ onContainerAwoken()
void Dobby::onContainerAwoken |
( |
int32_t |
cd, |
|
|
const ContainerId & |
id |
|
) |
| |
|
private |
Called by the DobbyManager code when a container returns back from hibernated.
- Parameters
-
[in] | cd | The container unique descriptor. |
[in] | id | The string id / name of the container. |
◆ onContainerHibernated()
void Dobby::onContainerHibernated |
( |
int32_t |
cd, |
|
|
const ContainerId & |
id |
|
) |
| |
|
private |
Called by the DobbyManager code when a container gets hibernated.
- Parameters
-
[in] | cd | The container unique descriptor. |
[in] | id | The string id / name of the container. |
◆ onContainerStarted()
void Dobby::onContainerStarted |
( |
int32_t |
cd, |
|
|
const ContainerId & |
id |
|
) |
| |
|
private |
Called by the DobbyManager code when a container has started.
This is typically called from DobbyManager in response to a DobbyManager::onPostStartHook, so just beware it's recursive from the dbus thread POV.
- Parameters
-
[in] | cd | The container unique descriptor. |
[in] | id | The string id / name of the container. |
◆ onContainerStopped()
void Dobby::onContainerStopped |
( |
int32_t |
cd, |
|
|
const ContainerId & |
id, |
|
|
int |
status |
|
) |
| |
|
private |
Called by the DobbyManager code when a container has stopped.
This is typically called from an internal thread in the DobbyManager so be careful of any threading issues.
- Parameters
-
[in] | cd | The container unique descriptor. |
[in] | id | The string id / name of the container. |
[in] | status | The status result of the container's runc process. |
◆ setDefaultAIDbusAddresses()
void Dobby::setDefaultAIDbusAddresses |
( |
const std::string & |
aiPrivateBusAddress, |
|
|
const std::string & |
aiPublicBusAddress |
|
) |
| |
Debugging function for manually setting the AI dbus addresses.
- Parameters
-
[in] | aiPrivateBusAddress | The AI private dbus address |
[in] | aiPublicBusAddress | The AI public dbus address |
◆ setupLogging()
void Dobby::setupLogging |
( |
unsigned |
targets = LogTarget::Console | ) |
|
|
static |
Static method must be called early in the startup before object is instantiated.
If the function detects the ETHAN_LOGGING_PIPE env var then it sets the default logging method to 'ethan log', otherwise it defaults to syslog.
◆ mEthanLogPipeFd
int Dobby::mEthanLogPipeFd = -1 |
|
staticprivate |
The fd of the ethan logging pipe, starts off pointing to /dev/null but can changed dynamically via dbus
The documentation for this class was generated from the following files:
- daemon/lib/include/Dobby.h
- daemon/lib/source/Dobby.cpp