Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2099A2004F2 for ; Sat, 26 Aug 2017 11:07:31 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1F0CC168614; Sat, 26 Aug 2017 09:07:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 65F8F168611 for ; Sat, 26 Aug 2017 11:07:30 +0200 (CEST) Received: (qmail 96826 invoked by uid 500); 26 Aug 2017 09:07:29 -0000 Mailing-List: contact commits-help@atlas.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.apache.org Delivered-To: mailing list commits@atlas.apache.org Received: (qmail 96817 invoked by uid 99); 26 Aug 2017 09:07:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Aug 2017 09:07:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 55FA6E0019; Sat, 26 Aug 2017 09:07:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: madhan@apache.org To: commits@atlas.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: atlas git commit: ATLAS-1218: Atlas says it is started but does not accept REST requests Date: Sat, 26 Aug 2017 09:07:27 +0000 (UTC) archived-at: Sat, 26 Aug 2017 09:07:31 -0000 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 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 Authored: Sat Aug 26 02:06:59 2017 -0700 Committer: Madhan Neethiraj 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: