82 lines
No EOL
2.2 KiB
C
82 lines
No EOL
2.2 KiB
C
/**
|
|
* @file xcecd_dbus_manager.h
|
|
* @brief This file contains the declaration of the D-Bus manager functions.
|
|
* It uses to manage worker and its child process with resource limits.
|
|
*/
|
|
#ifndef _XCECD_DBUS_MANAGER_H_
|
|
#define _XCECD_DBUS_MANAGER_H_
|
|
|
|
#include "sqlite3.h"
|
|
#include "xcecd_cgroups.h"
|
|
#include "xcecd_worker_utils.h"
|
|
#include "xcecd_utils.h"
|
|
#include <stdbool.h>
|
|
|
|
|
|
/**
|
|
* @brief Start worker with resource limits
|
|
*
|
|
* @param limits resource limits (NULL if no limits)
|
|
* @param job_id job id
|
|
* @param extra_args extra command line arguments (NULL if none)
|
|
* @return true if success, false if failed
|
|
*/
|
|
bool dbus_start_worker(const res_limits_t* limits,
|
|
uint64_t job_id, char* extra_args);
|
|
|
|
/**
|
|
* @brief Stop a worker service
|
|
*
|
|
* @param unit_name worker service name (xcecd-worker-<job_id>.service)
|
|
* @return true if success, false if failed
|
|
*/
|
|
bool dbus_stop_worker(const char* unit_name);
|
|
|
|
/**
|
|
* @brief Get PID of a worker service
|
|
*
|
|
* @param unit_name worker service name (xcecd-worker-<job_id>.service)
|
|
* @return PID if success, -1 if failed
|
|
*/
|
|
pid_t dbus_get_worker_pid(const char* unit_name);
|
|
|
|
/**
|
|
* @brief Check if a worker service is active
|
|
*
|
|
* @param unit_name worker service name (xcecd-worker-<job_id>.service)
|
|
* @return true if active, false if not active
|
|
*/
|
|
bool dbus_is_worker_active(const char* unit_name);
|
|
|
|
/**
|
|
* @brief Update worker status
|
|
*
|
|
* @param worker_list worker list
|
|
* @param job job information
|
|
* @param db database information
|
|
* @return XCECD_OK if success, others in execd_error if failed
|
|
*/
|
|
int dbus_workers_update(xcecd_worker_t** worker_list,
|
|
xcecd_job_t* job,
|
|
sqlite3* db);
|
|
|
|
/**
|
|
* @brief Clean worker service
|
|
*
|
|
* @param worker worker information
|
|
* @param job job information
|
|
* @return true if success, false if failed
|
|
*/
|
|
bool dbus_worker_clean(xcecd_worker_t* worker,
|
|
xcecd_job_t* job);
|
|
|
|
/**
|
|
* @brief Go through worker list and stop all workers
|
|
* @param worker_list worker list
|
|
* @param db database information
|
|
* @return void
|
|
*/
|
|
void dbus_stop_all_workers(xcecd_worker_t** worker_list,
|
|
sqlite3* db);
|
|
|
|
#endif // _XCECD_DBUS_MANAGER_H_
|