Changeset: b634abd1fac0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b634abd1fac0
Modified Files:
        tools/merovingian/daemon/merovingian.c
Branch: Apr2011
Log Message:

merovingian: deduce mserver5 location from binpath

For relocatable installations (such as an OSX .app bundle), it is useful
when the location of the mserver5 to use is determined at runtime, like
mserver5 determines where its loadable modules are.


diffs (48 lines):

diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -529,8 +529,22 @@
        srand(time(NULL));
        /* figure out our hostname */
        gethostname(_mero_hostname, 128);
-       /* where is the mserver5 binary we fork on demand? */
-       _mero_mserver = BINDIR "/mserver5";
+       /* where is the mserver5 binary we fork on demand?
+        * first try to locate it based on our binary location, fall-back to
+        * hardcoded bin-dir */
+       _mero_mserver = get_bin_path();
+       if (_mero_mserver != NULL) {
+               /* replace the trailing monetdbd by mserver5, fits nicely since
+                * they happen to be of same length */
+               char *s = strrchr(_mero_mserver, '/');
+               if (s != NULL && strcmp(s + 1, "monetdbd") == 0) {
+                       s++;
+                       *s++ = 'm'; *s++ = 's'; *s++ = 'e'; *s++ = 'r';
+                       *s++ = 'v'; *s++ = 'e'; *s++ = 'r'; *s++ = '5';
+                       if (stat(_mero_mserver, &sb) == -1)
+                               _mero_mserver = NULL;
+               }
+       }
        /* setup default database properties, constants: unlike previous
         * versions, we do not want changing defaults any more */
        _mero_db_props = getDefaultProps();
@@ -591,11 +605,14 @@
                MERO_EXIT_CLEAN(1);
        }
 
-       /* exit early if this is not going to work well */
-       if (stat(_mero_mserver, &sb) == -1) {
-               Mfprintf(stderr, "cannot stat %s executable: %s\n",
-                               _mero_mserver, strerror(errno));
-               MERO_EXIT_CLEAN(1);
+       if (_mero_mserver == NULL) {
+               _mero_mserver = BINDIR "/mserver5";
+               if (stat(_mero_mserver, &sb) == -1) {
+                       /* exit early if this is not going to work well */
+                       Mfprintf(stderr, "cannot stat %s executable: %s\n",
+                                       _mero_mserver, strerror(errno));
+                       MERO_EXIT_CLEAN(1);
+               }
        }
 
        /* read the merovingian properties from the dbfarm */
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to