You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2016/10/08 12:22:33 UTC

svn commit: r1763895 - /uima/uima-ducc/trunk/src/main/admin/db_create

Author: degenaro
Date: Sat Oct  8 12:22:33 2016
New Revision: 1763895

URL: http://svn.apache.org/viewvc?rev=1763895&view=rev
Log:
UIMA-5138 DUCC Database (db) db_create should abort if db already running

Modified:
    uima/uima-ducc/trunk/src/main/admin/db_create

Modified: uima/uima-ducc/trunk/src/main/admin/db_create
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/admin/db_create?rev=1763895&r1=1763894&r2=1763895&view=diff
==============================================================================
--- uima/uima-ducc/trunk/src/main/admin/db_create (original)
+++ uima/uima-ducc/trunk/src/main/admin/db_create Sat Oct  8 12:22:33 2016
@@ -86,7 +86,23 @@ class DbCreate(DuccUtil):
             elif o in ('-h', '-?', '--help'):
                 self.usage(None)
         
-
+        # abort db create if db already running
+        status = 'unknown'
+        cmd = self.DUCC_HOME+'/cassandra-server/bin/nodetool'
+        p = subprocess.Popen([cmd, 'info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        out, err = p.communicate()
+        if ((err != None) and (err != '')):
+            if (err.startswith(self.cmd_name_nodetool+': Failed to connect')):
+                status = 'down'
+        elif ((out != None) and (out != '')):
+            for line in out.splitlines():
+                if(line.startswith('Uptime')):
+                    status = 'up'
+                    break
+        if(status != 'down'):
+            print 'unsafe to proceed, database status: '+status
+            return
+    
         if ( self.database_pw == None ):
             self.database_pw = self.generate_pw()