Server /etc parameters embryon, clean shutdown (&signals), model storage dir
This commit is contained in:
parent
1251b2dcbb
commit
da226b3cfa
12
Makefile
12
Makefile
|
@ -87,11 +87,19 @@ all: dependencies $(BINDIR)/gem-graph-server $(BINDIR)/gem-graph-ctl
|
||||||
tests: $(TESTS)
|
tests: $(TESTS)
|
||||||
|
|
||||||
# ---- Build debian package -------------------------------------------------- #
|
# ---- Build debian package -------------------------------------------------- #
|
||||||
$(BINDIR)/gem-graph-server.deb: all
|
$(BINDIR)/gem-graph-server.deb: all $(DEBDIR)/control \
|
||||||
|
$(DEBDIR)/conffiles \
|
||||||
|
$(DEBDIR)/etc/server.conf \
|
||||||
|
$(DEBDIR)/copyright
|
||||||
mkdir -p gem-graph-server/usr/bin
|
mkdir -p gem-graph-server/usr/bin
|
||||||
|
mkdir -p gem-graph-server/var/lib/gem-graph-server/models
|
||||||
|
mkdir -p gem-graph-server/var/lib/gem-graph-server/users
|
||||||
|
mkdir -p gem-graph-server/etc/gem-graph-server
|
||||||
mkdir -p gem-graph-server/usr/share/doc/gem-graph-server
|
mkdir -p gem-graph-server/usr/share/doc/gem-graph-server
|
||||||
mkdir -p gem-graph-server/DEBIAN
|
mkdir -p gem-graph-server/DEBIAN
|
||||||
cp $(DEBDIR)/Manifest gem-graph-server/DEBIAN/control
|
cp $(DEBDIR)/control gem-graph-server/DEBIAN/control
|
||||||
|
cp $(DEBDIR)/conffiles gem-graph-server/DEBIAN/conffiles
|
||||||
|
cp $(DEBDIR)/etc/* gem-graph-server/etc/gem-graph-server
|
||||||
cp $(BINDIR)/gem-graph-server gem-graph-server/usr/bin
|
cp $(BINDIR)/gem-graph-server gem-graph-server/usr/bin
|
||||||
cp $(BINDIR)/gem-graph-ctl gem-graph-server/usr/bin
|
cp $(BINDIR)/gem-graph-ctl gem-graph-server/usr/bin
|
||||||
cp $(DEBDIR)/copyright \
|
cp $(DEBDIR)/copyright \
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
Package: gem-graph-server
|
|
||||||
Version: 0.0.1
|
|
||||||
Section: custom
|
|
||||||
Priority: optional
|
|
||||||
Depends: libxml2
|
|
||||||
Architecture: amd64
|
|
||||||
Essential: no
|
|
||||||
Installed-Size: 1049
|
|
||||||
Maintainer: The Gem-graph Project
|
|
||||||
Description: The gem-graph computation server
|
|
|
@ -168,3 +168,14 @@ struct {
|
||||||
Scheduler_t *scheduler;
|
Scheduler_t *scheduler;
|
||||||
Supervisor_t *supervisor;
|
Supervisor_t *supervisor;
|
||||||
} typedef Model_t;
|
} typedef Model_t;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
//
|
||||||
|
// Parameters
|
||||||
|
//
|
||||||
|
struct {
|
||||||
|
char *configDir;
|
||||||
|
char *modelDir;
|
||||||
|
char *userDir;
|
||||||
|
} typedef Parameters_t;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "../include/base.h"
|
#include "../include/base.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ModelSystemInit(void);
|
void ModelSystemInit(Parameters_t *parameters);
|
||||||
|
|
||||||
void ModelSystemDestroy(void);
|
void ModelSystemDestroy(void);
|
||||||
|
|
||||||
|
|
|
@ -179,12 +179,12 @@ CmdModelEnd:
|
||||||
|
|
||||||
char *CmdShutdown(char *buf, char **argv, Server_t *args)
|
char *CmdShutdown(char *buf, char **argv, Server_t *args)
|
||||||
{
|
{
|
||||||
ModelShutdown();
|
|
||||||
strcat(buf, "All model shutted down\n");
|
|
||||||
|
|
||||||
args->pleaseStop = true;
|
args->pleaseStop = true;
|
||||||
strcat(buf, "Server stopping\n");
|
strcat(buf, "Server stopping\n");
|
||||||
|
|
||||||
|
ModelShutdown();
|
||||||
|
strcat(buf, "All model shutted down\n");
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ static void *workerMain(void *worker)
|
||||||
printLog("Worker #%lu online\n", args->id);
|
printLog("Worker #%lu online\n", args->id);
|
||||||
|
|
||||||
int size = args->globalDrawingSpace->size;
|
int size = args->globalDrawingSpace->size;
|
||||||
|
|
||||||
/* In each cell: the West (left) site is 0, the East (right) site is 1 */
|
/* In each cell: the West (left) site is 0, the East (right) site is 1 */
|
||||||
for (int orig=0; orig < size; orig++){
|
for (int orig=0; orig < size; orig++){
|
||||||
int nxt1 = (orig + 1) % size,
|
int nxt1 = (orig + 1) % size,
|
||||||
|
|
47
src/main.c
47
src/main.c
|
@ -23,37 +23,66 @@
|
||||||
#include "../include/server.h"
|
#include "../include/server.h"
|
||||||
#include "../include/model.h"
|
#include "../include/model.h"
|
||||||
|
|
||||||
|
static Server_t *server;
|
||||||
|
|
||||||
|
void SigIntTermHandler(int signum)
|
||||||
|
{
|
||||||
|
server->pleaseStop = true;
|
||||||
|
printLog("Server stopping\n");
|
||||||
|
|
||||||
|
ModelShutdown();
|
||||||
|
printLog("All model shutted down\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO parse args to discover :
|
||||||
|
// - config files directory
|
||||||
|
// - models & users directories
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
time_t t;
|
time_t t;
|
||||||
Server_t *server0;
|
|
||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
|
|
||||||
|
// Get parameters TODO from args
|
||||||
|
Parameters_t *parameters = (Parameters_t*) calloc(sizeof(Parameters_t), 1);
|
||||||
|
|
||||||
|
parameters->configDir = (char*) malloc(strlen("../debian/etc"));
|
||||||
|
strcpy(parameters->configDir, "../debian/etc");
|
||||||
|
|
||||||
|
parameters->modelDir = (char*) malloc(strlen("../debian/var/models"));
|
||||||
|
strcpy(parameters->modelDir, "../debian/etc");
|
||||||
|
|
||||||
|
parameters->userDir = (char*) malloc(strlen("../debian/var/users"));
|
||||||
|
strcpy(parameters->userDir, "../debian/etc");
|
||||||
|
|
||||||
// Go!
|
// Go!
|
||||||
printLog("Starting gem-graph-server...\n");
|
printLog("Starting gem-graph-server...\n");
|
||||||
|
|
||||||
|
// Register new interrupt handler
|
||||||
|
signal(SIGINT, SigIntTermHandler);
|
||||||
|
signal(SIGTERM, SigIntTermHandler);
|
||||||
|
|
||||||
// Initializing random generator
|
// Initializing random generator
|
||||||
t = time(&t);
|
t = time(&t);
|
||||||
srand((unsigned) t);
|
srand((unsigned) t);
|
||||||
|
|
||||||
server0 = (Server_t*) calloc(1, sizeof(Server_t));
|
server = (Server_t*) calloc(1, sizeof(Server_t));
|
||||||
|
|
||||||
// Initializing model system
|
// Initializing model system
|
||||||
ModelSystemInit();
|
ModelSystemInit(parameters);
|
||||||
|
|
||||||
// Launching server
|
// Launching server
|
||||||
ServerInit(server0);
|
ServerInit(server);
|
||||||
|
|
||||||
// Waiting for termination
|
// Waiting for termination
|
||||||
ServerWait(server0);
|
ServerWait(server);
|
||||||
|
|
||||||
// Exiting
|
// Exiting
|
||||||
returnValue |= server0->returnValue;
|
returnValue |= server->returnValue;
|
||||||
ServerDestroy(server0);
|
ServerDestroy(server);
|
||||||
ModelSystemDestroy();
|
ModelSystemDestroy();
|
||||||
free(server0);
|
free(server);
|
||||||
server0 = NULL;
|
server = NULL;
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,15 +182,16 @@ void ModelShutdown(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelSystemInit(void)
|
void ModelSystemInit(Parameters_t *parameters)
|
||||||
{
|
{
|
||||||
loadedModel = (Model_t**) calloc(1, sizeof(Model_t*));
|
loadedModel = (Model_t**) calloc(1, sizeof(Model_t*));
|
||||||
|
|
||||||
// XXX read known models from files
|
|
||||||
knownModel = (Model_t**) calloc(1, sizeof(Model_t*));
|
knownModel = (Model_t**) calloc(1, sizeof(Model_t*));
|
||||||
|
|
||||||
knownModelSize = 0;
|
knownModelSize = 0;
|
||||||
loadedModelSize = 0;
|
loadedModelSize = 0;
|
||||||
|
|
||||||
|
printLog("Model system initiated with folder : %s\n", parameters->modelDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelSystemDestroy(void)
|
void ModelSystemDestroy(void)
|
||||||
|
|
BIN
src/tests/xml
BIN
src/tests/xml
Binary file not shown.
|
@ -8,8 +8,8 @@ void parseStory (xmlDocPtr doc, xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
cur = cur->xmlChildrenNode;
|
cur = cur->xmlChildrenNode;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) {
|
if ((!xmlStrcmp(cur->name, (const xmlChar *)"authors"))) {
|
||||||
printf("keyword: %s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
|
printf("%s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue