Окунев Дмитрий Юрьевич

Updated for clsync-0.4

... ... @@ -54,7 +54,7 @@ pdcp - это утилита позволяющая производить ко
Запуск на master-узле:
clsync -M direct -S $(which pdcp) -W /opt/global -b -Y syslog -- -a %FILE-LIST%
clsync -M simple -S $(which pdcp) -W /opt/global -b -Y syslog -- -a %INCLUDE-LIST% %INCLUDE-LIST%
Готово, можно попробовать:
... ... @@ -90,79 +90,10 @@ uftp - это утилита позволяющая организовывать
# pdsh -a echo uftpd -M 248.225.233.1 -D /opt/production \> /etc/rc.local # или в другое место, в зависимости от вашей системы
# pdsh -a uftpd -M 248.225.233.1 -D /opt/production
Доподготовка master-узла:
cat > /root/uftp-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+5; // "uftp" + "-M" + ip-address + n*path + NULL
argv = xmalloc(argv_size * sizeof(char *));
argv[0] = "/usr/local/bin/uftp";
argv[1] = "-M";
argv[2] = "248.225.233.1";
int i = 3;
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/uftp-handler.c -o /root/uftp-handler.so
Запуск на master-узле:
clsync --mode=so --sync-handler=/root/uftp-handler.so --watch-dir=/opt/global --background=1 --output=syslog
clsync --mode=direct --sync-handler=uftp --watch-dir=/opt/global --background=1 --output=syslog -- -M 248.225.233.1 %INCLUDE-LIST%
Готово, можно попробовать:
date >> /opt/global/test.log
\ No newline at end of file
... ...