diff options
author | Csaba Henk <csaba@gluster.com> | 2011-04-18 17:25:27 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-19 02:30:28 -0700 |
commit | 5a0d15682fb62d768ce088b5d9c9aad974a1460c (patch) | |
tree | c39030c8f1a912ccd8482a3751b46914fa4e0700 /xlators | |
parent | 0a38334bd3b21df2448a869760292c499c59bb0c (diff) |
gsyncd service auto-discovery
If glusterd is running, gsyncd will find it out and adopt related settings
automagically (even if started from not by glusterd)
Signed-off-by: Csaba Henk <csaba@lowlife.hu>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2785 (gsyncd logs on slave side go to /dev/null)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2785
Diffstat (limited to 'xlators')
-rwxr-xr-x | xlators/features/marker/utils/gsyncd.in | 50 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 2 |
2 files changed, 51 insertions, 1 deletions
diff --git a/xlators/features/marker/utils/gsyncd.in b/xlators/features/marker/utils/gsyncd.in index c34fea1a1..a7af8c0b0 100755 --- a/xlators/features/marker/utils/gsyncd.in +++ b/xlators/features/marker/utils/gsyncd.in @@ -3,5 +3,53 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" libexecdir=`eval echo "@libexecdir@"` +sbindir=`eval echo "@sbindir@"` -exec @PYTHON@ "$libexecdir"/glusterfs/python/syncdaemon/gsyncd.py "$@" +gluster="$sbindir"/gluster + +# glusterd service autodetection + +config_wanted=1 +if [ "$_GLUSTERD_CALLED_" = 1 ]; then + # OK, we know glusterd called us, no need to look for further config + config_wanted=0 + # ... altough this conclusion should not inherit to our children + unset _GLUSTERD_CALLED_ +else + # look for a -c option -- if present, we are already configured. + + for a in "$@"; do + # -c found, see if it has an argument + if [ "$one_more_arg" = 1 ]; then + if echo "$a" | grep -qv ^-; then + config_wanted=0 + break + fi + one_more_arg=0 + fi + + if [ "$a" = -c ] || [ "$a" = --config-file ]; then + one_more_arg=1 + continue + fi + + if echo $a | grep -qE '^(-c.|--config-file=)'; then + config_wanted=0; + break + fi + done + +fi + +if [ $config_wanted = 1 ]; then + wd="`${gluster} system:: getwd`" + if [ $? -eq 0 ]; then + config_file="$wd/geo-replication/gsyncd.conf" + fi +fi + +if [ -z "$config_file" ]; then + exec @PYTHON@ "$libexecdir"/glusterfs/python/syncdaemon/gsyncd.py "$@" +else + exec @PYTHON@ "$libexecdir"/glusterfs/python/syncdaemon/gsyncd.py -c "$config_file" "$@" +fi diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 9048edc26..4d98fafd7 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -238,6 +238,8 @@ configure_syncaemon (xlator_t *this, const char *workdir) char cmd[4096] = {0,}; int blen = 0; + setenv ("_GLUSTERD_CALLED_", "1", 1); + snprintf (voldir, PATH_MAX, "%s/"GEOREP, workdir); ret = mkdir (voldir, 0777); if ((-1 == ret) && (errno != EEXIST)) { |