You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/08/26 09:07:27 UTC

atlas git commit: ATLAS-1218: Atlas says it is started but does not accept REST requests

Repository: atlas
Updated Branches:
  refs/heads/master c6155816c -> cba5f7622


ATLAS-1218: Atlas says it is started but does not accept REST requests

Signed-off-by: Madhan Neethiraj <ma...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/cba5f762
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/cba5f762
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/cba5f762

Branch: refs/heads/master
Commit: cba5f7622b0724b158e93ac3d9cd7bd8de6d4c2b
Parents: c615581
Author: Richard Ding <rd...@yahoo-inc.com>
Authored: Sat Aug 26 02:06:59 2017 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Sat Aug 26 02:06:59 2017 -0700

----------------------------------------------------------------------
 distro/src/bin/atlas_config.py | 51 +++++++++++++++++++++++++++++++++++++
 distro/src/bin/atlas_start.py  |  4 +--
 2 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/cba5f762/distro/src/bin/atlas_config.py
----------------------------------------------------------------------
diff --git a/distro/src/bin/atlas_config.py b/distro/src/bin/atlas_config.py
index 1be9ca2..ada5743 100755
--- a/distro/src/bin/atlas_config.py
+++ b/distro/src/bin/atlas_config.py
@@ -23,6 +23,7 @@ import subprocess
 import sys
 import time
 import errno
+import socket
 from re import split
 from time import sleep
 
@@ -65,6 +66,11 @@ SOLR_INDEX_CONF_ENTRY="atlas.graph.index.search.backend\s*=\s*solr5"
 SOLR_INDEX_LOCAL_CONF_ENTRY="atlas.graph.index.search.solr.zookeeper-url\s*=\s*localhost"
 SOLR_INDEX_ZK_URL="atlas.graph.index.search.solr.zookeeper-url"
 TOPICS_TO_CREATE="atlas.notification.topics"
+ATLAS_HTTP_PORT="atlas.server.http.port"
+ATLAS_HTTPS_PORT="atlas.server.https.port"
+DEFAULT_ATLAS_HTTP_PORT="21000"
+DEFAULT_ATLAS_HTTPS_PORT="21443"
+ATLAS_ENABLE_TLS="atlas.enableTLS"
 
 DEBUG = False
 
@@ -442,6 +448,45 @@ def get_topics_to_create(confdir):
         topics = ["ATLAS_HOOK", "ATLAS_ENTITIES"]
     return topics
 
+def get_atlas_url_port(confdir):
+    port = None
+    if '-port' in sys.argv:
+        port = sys.argv[sys.argv.index('-port')+1]
+
+    if port is None:
+        confdir = os.path.join(confdir, CONF_FILE)
+        enable_tls = getConfig(confdir, ATLAS_ENABLE_TLS)
+        if enable_tls is not None and enable_tls.lower() == 'true':
+            port = getConfigWithDefault(confdir, ATLAS_HTTPS_PORT, DEFAULT_ATLAS_HTTPS_PORT)
+        else:
+            port = getConfigWithDefault(confdir, ATLAS_HTTP_PORT, DEFAULT_ATLAS_HTTP_PORT)
+
+    print "starting atlas on port %s" % port
+    return port
+
+def wait_for_startup(confdir, wait):
+    count = 0
+    port = get_atlas_url_port(confdir)
+    while True:
+        try:
+            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            s.settimeout(1)
+            s.connect(('localhost', int(port)))
+            s.close()
+            break
+        except Exception as e:
+            # Wait for 1 sec before next ping
+            sys.stdout.write('.')
+            sys.stdout.flush()
+            sleep(1)
+
+        if count > wait:
+            s.close()
+            break
+
+        count = count + 1
+
+    sys.stdout.write('\n')
 
 def run_solr(dir, action, zk_url = None, port = None, logdir = None, wait=True):
 
@@ -525,6 +570,12 @@ def getConfig(file, key):
             return line.split('=')[1].strip()
     return None
 
+def getConfigWithDefault(file, key, defaultValue):
+    value = getConfig(file, key)
+    if value is None:
+        value = defaultValue
+    return value
+
 def isCygwin():
     return platform.system().startswith("CYGWIN")
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/cba5f762/distro/src/bin/atlas_start.py
----------------------------------------------------------------------
diff --git a/distro/src/bin/atlas_start.py b/distro/src/bin/atlas_start.py
index a6a3455..5ea93fc 100755
--- a/distro/src/bin/atlas_start.py
+++ b/distro/src/bin/atlas_start.py
@@ -131,6 +131,8 @@ def main():
         web_app_path = mc.convertCygwinPath(web_app_path)
     if not is_setup:
         start_atlas_server(atlas_classpath, atlas_pid_file, jvm_logdir, jvm_opts_list, web_app_path)
+        mc.wait_for_startup(confdir, 300)
+        print "Apache Atlas Server started!!!\n"
     else:
         process = mc.java("org.apache.atlas.web.setup.AtlasSetup", [], atlas_classpath, jvm_opts_list, jvm_logdir)
         return process.wait()
@@ -141,8 +143,6 @@ def start_atlas_server(atlas_classpath, atlas_pid_file, jvm_logdir, jvm_opts_lis
     args.extend(sys.argv[1:])
     process = mc.java("org.apache.atlas.Atlas", args, atlas_classpath, jvm_opts_list, jvm_logdir)
     mc.writePid(atlas_pid_file, process)
-    print "Apache Atlas Server started!!!\n"
-
 
 if __name__ == '__main__':
     try: