Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
articles
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2014-06-10 17:42:19 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2a15ab74dce81bf2314e208648928fd2f8d5a7d3
2a15ab74
1 parent
46e1d451
Adapted pdcp to clsync 0.4-rc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
68 deletions
clsync/inotify-to-many-nodes
clsync/inotify-to-many-nodes
View file @
2a15ab7
...
...
@@ -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%
Готово, можно попробовать:
...
...
Please
register
or
login
to post a comment