summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-04-03 15:44:17 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-04-04 08:02:30 -0700
commitf338193a707ae5b6b5ab6f820bea32612c4311bb (patch)
tree940842ac59eeb180f892ac8d379219b994b83a11 /cli/src
parent01b3dff29adee2041b0ef1b374eda8c88fb07678 (diff)
syncdaemon: refine intermal configuration of gsyncdv3.2.0qa7
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2561 (gsyncd command's must be preconfigured) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2561
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-rpc-ops.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 110962c6c..c358192d2 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -26,6 +26,7 @@
#ifndef GSYNC_CONF
#define GSYNC_CONF "gsync/gsyncd.conf"
#endif
+#define DEFAULT_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs"
#include "cli.h"
#include "compat-errno.h"
@@ -2609,7 +2610,7 @@ gf_cli3_1_gsync_get_param_file (char *prmfile, const char *ext, char *master, ch
char buff[PATH_MAX] = {0, };
char cmd[PATH_MAX] = {0, };
char *ptr = NULL;
- char pidfolder[PATH_MAX] = {0, };
+ char prmfolder[PATH_MAX] = {0, };
char *dotp = NULL;
int ret = 0;
@@ -2637,7 +2638,7 @@ gf_cli3_1_gsync_get_param_file (char *prmfile, const char *ext, char *master, ch
ptr = fgets(buff, sizeof(buff), in);
if (ptr) {
buff[strlen(buff)-1]='\0'; //strip off \n
- snprintf (pidfolder, PATH_MAX, "%s/gsync/%s", gl_workdir, buff);
+ snprintf (prmfolder, PATH_MAX, "%s/gsync/%s", gl_workdir, buff);
} else {
ret = -1;
goto out;
@@ -2648,7 +2649,7 @@ gf_cli3_1_gsync_get_param_file (char *prmfile, const char *ext, char *master, ch
ptr = fgets(buff, sizeof(buff), in);
if (ptr) {
buff[strlen(buff)-1]='\0'; //strip off \n
- snprintf (prmfile, PATH_MAX, "%s/%s.pid", pidfolder, buff);
+ snprintf (prmfile, PATH_MAX, "%s/%s.%s", prmfolder, buff, ext);
}
out:
@@ -2704,7 +2705,7 @@ gf_cli3_1_start_gsync (char *master, char *slave, char *gl_workdir)
if (ret == -1) {
ret = -1;
gf_log ("", GF_LOG_WARNING, "failed to construct the "
- "prmfile string");
+ "pidfile string");
goto out;
}
@@ -2766,6 +2767,60 @@ gf_cli3_1_start_gsync (char *master, char *slave, char *gl_workdir)
goto out;
}
+ ret = gf_cli3_1_gsync_get_param_file (prmfile, "log", master,
+ slave, DEFAULT_LOG_FILE_DIRECTORY);
+ if (ret == -1) {
+ gf_log ("", GF_LOG_WARNING, "failed to construct the "
+ "logfile string");
+ goto out;
+ }
+ /* XXX "mkdir -p": eventually this should be made into a library routine */
+ tslash = strrchr(prmfile, '/');
+ if (tslash) {
+ char *slash = prmfile;
+ struct stat st = {0,};
+
+ *tslash = '\0';
+ if (*slash == '/')
+ slash++;
+ while (slash) {
+ slash = strchr (slash, '/');
+ if (slash)
+ *slash = '\0';
+ ret = mkdir (prmfile, 0777);
+ if (ret == -1 && errno != EEXIST) {
+ gf_log ("", GF_LOG_DEBUG, "mkdir failed (%s)",
+ strerror (errno));
+ goto out;
+ }
+ if (slash) {
+ *slash = '/';
+ slash++;
+ }
+ }
+ ret = stat (prmfile, &st);
+ if (ret == -1 || !S_ISDIR (st.st_mode)) {
+ ret = -1;
+ gf_log ("", GF_LOG_DEBUG, "mkdir failed (%s)",
+ strerror (errno));
+ goto out;
+ }
+ *tslash = '/';
+ }
+
+ ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s %s %s"
+ " --config-set log-file %s", gl_workdir,
+ GSYNC_CONF, master, slave, prmfile);
+ if (ret >= PATH_MAX)
+ ret = -1;
+ if (ret != -1)
+ ret = system (cmd) ? -1 : 0;
+ if (ret == -1) {
+ gf_log ("", GF_LOG_WARNING, "failed to set status file "
+ "for %s %s", master, slave);
+ goto out;
+ }
+
memset (cmd, 0, sizeof (cmd));
ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd --monitor -c %s/%s %s %s"
, gl_workdir, GSYNC_CONF, master, slave);