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)
|
||||
|
||||
# ---- 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/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/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-ctl gem-graph-server/usr/bin
|
||||
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;
|
||||
Supervisor_t *supervisor;
|
||||
} typedef Model_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//
|
||||
// Parameters
|
||||
//
|
||||
struct {
|
||||
char *configDir;
|
||||
char *modelDir;
|
||||
char *userDir;
|
||||
} typedef Parameters_t;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
void ModelSystemInit(void);
|
||||
void ModelSystemInit(Parameters_t *parameters);
|
||||
|
||||
void ModelSystemDestroy(void);
|
||||
|
||||
|
|
|
@ -179,12 +179,12 @@ CmdModelEnd:
|
|||
|
||||
char *CmdShutdown(char *buf, char **argv, Server_t *args)
|
||||
{
|
||||
ModelShutdown();
|
||||
strcat(buf, "All model shutted down\n");
|
||||
|
||||
args->pleaseStop = true;
|
||||
strcat(buf, "Server stopping\n");
|
||||
|
||||
ModelShutdown();
|
||||
strcat(buf, "All model shutted down\n");
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ static void *workerMain(void *worker)
|
|||
printLog("Worker #%lu online\n", args->id);
|
||||
|
||||
int size = args->globalDrawingSpace->size;
|
||||
|
||||
/* In each cell: the West (left) site is 0, the East (right) site is 1 */
|
||||
for (int orig=0; orig < size; orig++){
|
||||
int nxt1 = (orig + 1) % size,
|
||||
|
|
47
src/main.c
47
src/main.c
|
@ -23,37 +23,66 @@
|
|||
#include "../include/server.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)
|
||||
{
|
||||
time_t t;
|
||||
Server_t *server0;
|
||||
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!
|
||||
printLog("Starting gem-graph-server...\n");
|
||||
|
||||
// Register new interrupt handler
|
||||
signal(SIGINT, SigIntTermHandler);
|
||||
signal(SIGTERM, SigIntTermHandler);
|
||||
|
||||
// Initializing random generator
|
||||
t = time(&t);
|
||||
srand((unsigned) t);
|
||||
|
||||
server0 = (Server_t*) calloc(1, sizeof(Server_t));
|
||||
server = (Server_t*) calloc(1, sizeof(Server_t));
|
||||
|
||||
// Initializing model system
|
||||
ModelSystemInit();
|
||||
ModelSystemInit(parameters);
|
||||
|
||||
// Launching server
|
||||
ServerInit(server0);
|
||||
ServerInit(server);
|
||||
|
||||
// Waiting for termination
|
||||
ServerWait(server0);
|
||||
ServerWait(server);
|
||||
|
||||
// Exiting
|
||||
returnValue |= server0->returnValue;
|
||||
ServerDestroy(server0);
|
||||
returnValue |= server->returnValue;
|
||||
ServerDestroy(server);
|
||||
ModelSystemDestroy();
|
||||
free(server0);
|
||||
server0 = NULL;
|
||||
free(server);
|
||||
server = NULL;
|
||||
|
||||
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*));
|
||||
|
||||
// XXX read known models from files
|
||||
knownModel = (Model_t**) calloc(1, sizeof(Model_t*));
|
||||
|
||||
knownModelSize = 0;
|
||||
loadedModelSize = 0;
|
||||
|
||||
printLog("Model system initiated with folder : %s\n", parameters->modelDir);
|
||||
}
|
||||
|
||||
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;
|
||||
while (cur != NULL) {
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) {
|
||||
printf("keyword: %s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"authors"))) {
|
||||
printf("%s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static void parseDoc(char *docname)
|
|||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL) {
|
||||
if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){
|
||||
parseStory (doc, cur);
|
||||
parseStory(doc, cur);
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue