You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/12/02 20:26:02 UTC

[04/50] [abbrv] ambari git commit: AMBARI-19000. Ambari-server fails to restart with --debug if it is already running (aonishuk)

AMBARI-19000. Ambari-server fails to restart with --debug if it is already running (aonishuk)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: e3b9a9f804537796fa46273b378935a14b75bb33
Parents: 28d7834
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed Nov 30 17:07:22 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed Nov 30 17:07:22 2016 +0200

----------------------------------------------------------------------
 ambari-server/src/main/python/ambari-server.py          | 12 +++++++++++-
 .../src/main/python/ambari_server/serverUtils.py        | 11 +++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3b9a9f8/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 41b2234..21bd0bb 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -35,7 +35,7 @@ from ambari_commons.os_utils import remove_file
 from ambari_server.BackupRestore import main as BackupRestore_main
 from ambari_server.dbConfiguration import DATABASE_NAMES, LINUX_DBMS_KEYS_LIST
 from ambari_server.serverConfiguration import configDefaults, get_ambari_properties, PID_NAME
-from ambari_server.serverUtils import is_server_runing, refresh_stack_hash
+from ambari_server.serverUtils import is_server_runing, refresh_stack_hash, wait_for_server_to_stop
 from ambari_server.serverSetup import reset, setup, setup_jce_policy
 from ambari_server.serverUpgrade import upgrade, upgrade_stack, set_current
 from ambari_server.setupHttps import setup_https, setup_truststore
@@ -63,6 +63,8 @@ logger = logging.getLogger()
 
 formatstr = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d - %(message)s"
 
+SERVER_STOP_TIMEOUT = 30
+
 class UserActionPossibleArgs(object):
   def __init__(self, i_fn, i_possible_args_numbers, *args, **kwargs):
     self.fn = i_fn
@@ -166,6 +168,14 @@ def stop(args):
     except OSError, e:
       print_info_msg("Unable to stop Ambari Server - " + str(e))
       return
+
+    print "Waiting for server stop..."
+    logger.info("Waiting for server stop...")
+
+    if not wait_for_server_to_stop(SERVER_STOP_TIMEOUT):
+      print "Ambari-server failed to stop"
+      logger.info("Ambari-server failed to stop")
+
     pid_file_path = os.path.join(configDefaults.PID_DIR, PID_NAME)
     os.remove(pid_file_path)
     print "Ambari Server stopped"

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3b9a9f8/ambari-server/src/main/python/ambari_server/serverUtils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverUtils.py b/ambari-server/src/main/python/ambari_server/serverUtils.py
index 3af233c..4621646 100644
--- a/ambari-server/src/main/python/ambari_server/serverUtils.py
+++ b/ambari-server/src/main/python/ambari_server/serverUtils.py
@@ -19,6 +19,7 @@ limitations under the License.
 '''
 
 import os
+import time
 from ambari_commons.exceptions import FatalException, NonFatalException
 from ambari_commons.logging_utils import get_verbose
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@@ -62,6 +63,16 @@ def is_server_runing():
     return False, None
 
 
+def wait_for_server_to_stop(wait_timeout):
+  start_time = time.time()
+  is_timeout = lambda: time.time() - start_time > wait_timeout
+
+  while is_server_runing()[0] and not is_timeout():
+    time.sleep(0.1)
+
+  return not is_timeout()
+
+
 @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY)
 def is_server_runing():
   from ambari_commons.os_windows import SERVICE_STATUS_STARTING, SERVICE_STATUS_RUNNING, SERVICE_STATUS_STOPPING, \