myxce/src/worker/include/xcecd.h
Rongsong Shen f0f46f87ad
chore(worker): remove dead config-file code (xcecd_conf)
xcecd_conf.c/h provided worker.yaml parsing (config_load, config_result_t).
Removed along with -c/-p/-m CLI flags. Worker now uses CLI defaults or --peers.
Deleted: include/xcecd_conf.h, src/xcecd_conf.c. meson.build updated.
2026-08-10 10:46:29 +00:00

100 lines
2.8 KiB
C

#ifndef XCECD_H
#define XCECD_H
#include "controller_connector.h"
#include "hardware_monitor.h"
#include "job_information.h"
#include "node_information.h"
#include "process_manager.h"
#include "resource_sync.h"
#include "static_array.h"
#include "system_monitor.h"
#include "thread_pool.h"
#include "uv_ipc.h"
#include "xcecd_db.h"
#include "xcecd_dbus_manager.h"
#include "xcecd_worker_utils.h"
#include "xcectx.h"
#include "xcelog.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#ifdef _WIN32
#include <pdh.h>
#include <windows.h>
#include <winsock2.h>
typedef HANDLE process_handle_t;
#else
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <unistd.h>
typedef pid_t process_handle_t;
#endif
#define REMOTE_PORT 6789
#define DEFAULT_PORT 0 // disable by default
#define BUFFER_SIZE 4096
#define RESTART_FLAG_FILE "/tmp/.xcecd.restarting"
typedef struct {
int thread_pool_size;
int resource_update_interval;
int job_status_update_interval;
uint16_t port;
const char* acct_file;
char* log_file;
const char* db_path;
const char* work_dir;
const char* domain_sock_file;
const char* remote_host;
const char* virutal_name;
int remote_port;
int join_interval;
int update_interval;
int domain_sock;
int debug_level;
} xcecd_config_t;
typedef struct {
thread_pool_t* thread_pool;
network_handler_t* network;
process_manager_t* process_manager;
system_monitor_t* system_monitor;
hardware_monitor_t* hardware_monitor;
resource_sync_t* resource_sync;
xcecd_worker_t* worker_list;
xcecd_db_t* db;
xce_ctx_t* xce_ctx;
bool running;
bool normal_restart;
char* remote_host;
int local_port;
int remote_port;
int update_interval;
int join_interval;
int domain_sock;
int debug_level;
char* work_dir;
char* log_dir;
char* db_path;
char* virtual_name;
} xcecd_context_t;
extern xcecd_context_t xcecd_ctx;
extern hostattrs_t host_attrs;
int xcecd_config_init(xcecd_config_t* config);
int xcecd_init(const xcecd_config_t* config);
int xcecd_start(void);
void xcecd_stop(void);
void xcecd_cleanup(void);
void xcecd_process_command(void* arg);
const char* handle_network_request(const char* request, void* user_data);
bool xcecd_config_is_valid(const xcecd_config_t* config);
void xcecd_prepare_restart(void);
bool xcecd_check_restart_type(void);
#endif // XCECD_H