AMBARI-18760 ambari-server.pid might not be created (additional patch) (dsen)

(cherry picked from commit 173d90c5b087cdaf0bd18ba4540121ac220db2e5)

Change-Id: I05a66d7efeaa2bf0806a3e06d09240c04c8ae877


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

Branch: refs/heads/AMBARI-2.4.2.16
Commit: 2d9455227ac33901b2efdac91b12807c61dc7d01
Parents: 4e4252c
Author: Dmytro Sen <[email protected]>
Authored: Thu Nov 17 17:38:05 2016 +0200
Committer: Dmytro Sen <[email protected]>
Committed: Thu Nov 17 16:25:15 2016 +0000

----------------------------------------------------------------------
 .../src/main/python/ambari_server/serverUtils.py        |  2 +-
 ambari-server/src/main/python/ambari_server/utils.py    | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2d945522/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 069e24d..3af233c 100644
--- a/ambari-server/src/main/python/ambari_server/serverUtils.py
+++ b/ambari-server/src/main/python/ambari_server/serverUtils.py
@@ -47,7 +47,7 @@ def is_server_runing():
     pid = f.readline().strip()
 
     if not pid.isdigit():
-      err = "%s is corrupt. Removing" % (pid_file_path)
+      err = "'%s' is incorrect PID value. %s is corrupt. Removing" % (pid, 
pid_file_path)
       f.close()
       run_os_command("rm -f " + pid_file_path)
       raise NonFatalException(err)

http://git-wip-us.apache.org/repos/asf/ambari/blob/2d945522/ambari-server/src/main/python/ambari_server/utils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/utils.py 
b/ambari-server/src/main/python/ambari_server/utils.py
index 5f0a64d..f505444 100644
--- a/ambari-server/src/main/python/ambari_server/utils.py
+++ b/ambari-server/src/main/python/ambari_server/utils.py
@@ -25,8 +25,11 @@ import sys
 import time
 import glob
 import subprocess
+import logging
 from ambari_commons import OSConst,OSCheck
 
+logger = logging.getLogger(__name__)
+
 # PostgreSQL settings
 PG_STATUS_RUNNING_DEFAULT = "running"
 PG_HBA_ROOT_DEFAULT = "/var/lib/pgsql/data"
@@ -104,13 +107,13 @@ def save_pid(pid, pidfile):
     pfile = open(pidfile, "w")
     pfile.write("%s\n" % pid)
   except IOError as e:
-    print_error_msg("Failed to write PID to " + pidfile + " due to " + str(e))
+    logger.error("Failed to write PID to " + pidfile + " due to " + str(e))
     pass
   finally:
     try:
       pfile.close()
     except Exception as e:
-      print_error_msg("Failed to close PID file " + pidfile + " due to " + 
str(e))
+      logger.error("Failed to close PID file " + pidfile + " due to " + str(e))
       pass
 
 
@@ -127,19 +130,20 @@ def save_main_pid_ex(pids, pidfile, exclude_list=[], 
kill_exclude_list=False, sk
     for item in pids:
       if pid_exists(item["pid"]) and (item["exe"] not in exclude_list):
         pfile.write("%s\n" % item["pid"])
+        logger.info("Ambari server started with PID " + str(item["pid"]))
       if pid_exists(item["pid"]) and (item["exe"] in exclude_list) and not 
skip_daemonize:
         try:
           os.kill(int(item["pid"]), signal.SIGKILL)
         except:
           pass
   except IOError as e:
-    print_error_msg("Failed to write PID to " + pidfile + " due to " + str(e))
+    logger.error("Failed to write PID to " + pidfile + " due to " + str(e))
     pass
   finally:
     try:
       pfile.close()
     except Exception as e:
-      print_error_msg("Failed to close PID file " + pidfile + " due to " + 
str(e))
+      logger.error("Failed to close PID file " + pidfile + " due to " + str(e))
       pass
 
 

Reply via email to