redmine

Adapted pdcp to clsync 0.4-rc3

... ... @@ -52,76 +52,9 @@ pdcp - это утилита позволяющая производить ко
ssh-copy-id "$IP"
done
Подготовка master-узла:
cat > /root/pdcp-handler.c << EOF
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <clsync/clsync.h>
#include <clsync/configuration.h>
#include <clsync/malloc.h>
#include <clsync/error.h>
struct ctx *ctx_p;
int clsyncapi_init(struct ctx *_ctx_p, struct indexes *_indexes_p) {
ctx_p = _ctx_p;
return 0;
}
int clsyncapi_sync(int n, api_eventinfo_t *ei) {
size_t argv_size;
char **argv;
debug(3, "n == %i", n);
if(n == 0)
return 0;
argv_size = n+4; // "pdcp" + "-a" + n*path + NULL
argv = xmalloc(argv_size * sizeof(char *));
argv[0] = "/usr/bin/pdcp";
argv[1] = "-a";
int i = 2;
int j = 0;
while (i < n) {
if(ei[j].path_len)
argv[i++] = (char*)ei[j].path;
j++;
}
argv[i++] = NULL;
int pid = clsyncapi_fork(ctx_p);
switch(pid) {
case -1:
critical("got error while clsyncapi_fork()");
case 0:
execv(argv[0], argv);
critical("got error while execv()");
}
int status;
if(waitpid(pid, &status, 0) != pid)
critical("got error while waitpid()");
int exitcode = WEXITSTATUS(status);
free(argv);
return exitcode;
}
EOF
gcc -march=native -O2 -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -ftree-loop-linear -ftree-loop-im -fweb -frename-registers -fomit-frame-pointer -fexcess-precision=fast -pipe --std=gnu11 -Wall -fPIC -shared -Wl,-O1,--as-needed /root/pdcp-handler.c -o /root/pdcp-handler.so
Запуск на master-узле:
clsync --mode=so --sync-handler=/root/pdcp-handler.so --watch-dir=/opt/global --background=1 --output=syslog
clsync -M direct -S $(which pdcp) -W /opt/global -b -Y syslog -- -a %FILE-LIST%
Готово, можно попробовать:
... ...