update controller code

This commit is contained in:
Rongsong Shen 2025-11-05 16:58:57 +08:00
parent 2836d196da
commit 41f56fa6ed
54 changed files with 9688 additions and 214 deletions

52
src/controller/myapp.c Normal file
View file

@ -0,0 +1,52 @@
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "cluster.h"
#include "myconf.h"
#include "netio.h"
#include "xce/cluster_def.h"
#include "request.h"
#include "utils.h"
time_t last_print_time = 0;
unsigned long npkts = 0;
unsigned long npkts_old = 0;
int myapp_run(myconf_t* myconf)
{
cluster_t c;
int rc;
c.myconf = myconf;
rc = cluster_init(&c);
if (rc < 0) {
SET_ERROR(-rc);
ERROR("cluster_init: %s", strerror(-rc));
cluster_fini(&c);
return rc;
}
rc = cluster_start(&c);
if (rc < 0) {
SET_ERROR(-rc);
perror("cluster_start");
cluster_fini(&c);
return rc;
}
rc = cluster_run(&c);
cluster_fini(&c);
return rc;
}