Changeset: 07db92d7cb30 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=07db92d7cb30
Modified Files:
        tools/merovingian/ChangeLog.Aug2011
        tools/merovingian/daemon/argvcmds.c
        tools/merovingian/daemon/controlrunner.c
Branch: Aug2011
Log Message:

monetdbd get: return version number of running merovingian

In order to shed some light in the merovingian forest on my local
machine, implemented the ability of monetdbd to return its own version
number.  This is now queried by `monetdbd get status` and returned for
each running monetdbd.  Now one can identify what version of merovingian
is serving a given dbfarm.


diffs (76 lines):

diff --git a/tools/merovingian/ChangeLog.Aug2011 
b/tools/merovingian/ChangeLog.Aug2011
--- a/tools/merovingian/ChangeLog.Aug2011
+++ b/tools/merovingian/ChangeLog.Aug2011
@@ -1,6 +1,9 @@
 # ChangeLog file for sql/src/backends/monet5/merovingian
 # This file is updated with mchangelog
 
+* Fri Oct  7 2011 Fabian Groffen <[email protected]>
+- monetdbd get status now also reports the version of the running monetdbd
+
 * Thu Oct  6 2011 Fabian Groffen <[email protected]>
 - Improved response time of 'monetdb start' when the database fails
   to start.
diff --git a/tools/merovingian/daemon/argvcmds.c 
b/tools/merovingian/daemon/argvcmds.c
--- a/tools/merovingian/daemon/argvcmds.c
+++ b/tools/merovingian/daemon/argvcmds.c
@@ -29,6 +29,7 @@
 #include <mutils.h> /* MT_lockf */
 #include <utils/utils.h>
 #include <utils/properties.h>
+#include <utils/control.h>
 
 #include "merovingian.h"
 #include "argvcmds.h"
@@ -247,8 +248,33 @@ command_get(confkeyval *ckv, int argc, c
                        value = buf;
                } else if (strcmp(p, "status") == 0) {
                        if (meropid > 0) {
+                               char *res;
+
+                               /* try to retrieve running merovingian version 
*/
+                               kv = findConfKey(ckv, "sockdir");
+                               value = kv->val;
+                               kv = findConfKey(ckv, "controlport");
+                               if (kv == NULL)
+                                       kv = findConfKey(ckv, "port"); /* 
forward compat */
+                               snprintf(buf, sizeof(buf), "%s/" CONTROL_SOCK 
"%d",
+                                               value, kv->ival);
+                               value = control_send(&res, buf, -1, "", 
"version", 0, NULL);
+                               if (value != NULL) {
+                                       free(value);
+                                       value = NULL;
+                               } else {
+                                       if (strncmp(res, "OK\n", 3) != 0) {
+                                               free(res);
+                                       } else {
+                                               value = res + 3;
+                                       }
+                               }
+
                                snprintf(buf, sizeof(buf),
-                                               "monetdbd[%d] is serving this 
dbfarm", meropid);
+                                               "monetdbd[%d] %s is serving 
this dbfarm",
+                                               meropid, value == NULL ? 
"(unknown version)" : value);
+                               if (value != NULL)
+                                       free(res);
                                value = buf;
                        } else if (meropid < 0) {
                                value = "a monetdbd is serving this dbfarm, "
diff --git a/tools/merovingian/daemon/controlrunner.c 
b/tools/merovingian/daemon/controlrunner.c
--- a/tools/merovingian/daemon/controlrunner.c
+++ b/tools/merovingian/daemon/controlrunner.c
@@ -628,6 +628,13 @@ controlRunner(void *d)
 
        /* comands below this point are multi line and hence you can't
         * combine them, so they disconnect the client afterwards */
+                               } else if (strcmp(p, "version") == 0) {
+                                       len = snprintf(buf2, sizeof(buf2), 
"OK\n");
+                                       send(msgsock, buf2, len, 0);
+                                       len = snprintf(buf2, sizeof(buf2), "%s 
(%s)\n",
+                                                       MERO_VERSION, 
MONETDB_RELEASE);
+                                       send(msgsock, buf2, len, 0);
+                                       break;
                                } else if (strcmp(p, "get") == 0) {
                                        confkeyval *props = getDefaultProps();
                                        char *pbuf;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to