summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-04-14 11:53:12 +0000
committerAnand Avati <avati@gluster.com>2011-04-14 11:41:26 -0700
commit4175e092e3521c1f095d6307ea9b05c7c49b02c6 (patch)
treef530e79b071bff2f3146dba4881ca0abff599137 /cli/src/cli-rpc-ops.c
parent4055c85a23043afdf3ad708d28aedc55805b1043 (diff)
mgmt/glusterd: restart gsyncd on glusterd restart
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2761 (Restart gsyncd processes on glusterd restart) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2761
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c156
1 files changed, 2 insertions, 154 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index a6665d1ed5d..9a2bb87f14e 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2756,156 +2756,6 @@ out:
}
int
-gf_cli3_1_start_gsync (char *master, char *slave, char *gl_workdir)
-{
- int32_t ret = -1;
- int32_t status = 0;
- char cmd[PATH_MAX] = {0,};
- char prmfile[PATH_MAX] = {0,};
- char *tslash = NULL;
-
- ret = gf_cli3_1_gsync_get_param_file (prmfile, "pid", master,
- slave, gl_workdir);
- if (ret == -1) {
- ret = -1;
- gf_log ("", GF_LOG_WARNING, "failed to construct the "
- "pidfile string");
- goto out;
- }
-
- ret = gf_cli3_1_gsync_status (master, slave, prmfile, &status);
- if ((ret == 0 && status == 0)) {
- gf_log ("", GF_LOG_WARNING, "gsync %s:%s"
- "already started", master, slave);
-
- cli_out ("gsyncd is already running");
-
- ret = -1;
- goto out;
- }
-
- unlink (prmfile);
-
- tslash = strrchr(prmfile, '/');
- if (tslash) {
- *tslash = '\0';
- ret = mkdir (prmfile, 0777);
- if (ret && (errno != EEXIST)) {
- gf_log ("", GF_LOG_DEBUG, "mkdir failed, errno: %d",
- errno);
- goto out;
- }
- *tslash = '/';
- }
-
- memset (cmd, 0, sizeof (cmd));
- ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s %s %s"
- " --config-set pid-file %s", gl_workdir,
- GSYNC_CONF, master, slave, prmfile);
- if (ret <= 0) {
- ret = -1;
- gf_log ("", GF_LOG_WARNING, "failed to construct the "
- "config set command for %s %s", master, slave);
- goto out;
- }
-
- ret = system (cmd);
- if (ret) {
- gf_log ("", GF_LOG_WARNING, "failed to set the pid "
- "option for %s %s", master, slave);
- goto out;
- }
-
- ret = gf_cli3_1_gsync_get_param_file (prmfile, "status", NULL, NULL, NULL);
- if (ret != -1)
- ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s %s %s"
- " --config-set state-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;
- }
-
- 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);
- if (ret <= 0) {
- ret = -1;
- goto out;
- }
-
- ret = system (cmd);
- if (ret == -1)
- goto out;
-
- cli_out ("gsync started");
- ret = 0;
-
-out:
-
- return ret;
-}
-
-int
gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
@@ -2943,11 +2793,9 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("%s", rsp.op_errstr ? rsp.op_errstr :
"command unsuccessful");
goto out;
- }
- else {
+ } else {
if (rsp.type == GF_GSYNC_OPTION_TYPE_START)
- ret = gf_cli3_1_start_gsync (rsp.master, rsp.slave,
- rsp.glusterd_workdir);
+ cli_out ("Gsync started Successfully");
else if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL
|| rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET)
ret = gf_cli3_1_gsync_get_command (rsp);