AMBARI-18760 ambari-server.pid might not be created (additional patch) (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2c884ab7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2c884ab7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2c884ab7 Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 2c884ab7b8fb935eb47f86d6b5a37c4dc6711252 Parents: 46b44d2 Author: Dmytro Sen <[email protected]> Authored: Thu Nov 17 17:38:05 2016 +0200 Committer: Dmytro Sen <[email protected]> Committed: Thu Nov 17 17:38:25 2016 +0200 ---------------------------------------------------------------------- .../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/2c884ab7/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/2c884ab7/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 1ff8d1e..5188a48 100644 --- a/ambari-server/src/main/python/ambari_server/utils.py +++ b/ambari-server/src/main/python/ambari_server/utils.py @@ -25,10 +25,13 @@ import sys import time import glob import subprocess +import logging from ambari_commons import OSConst,OSCheck from ambari_commons.logging_utils import print_error_msg from ambari_commons.exceptions import FatalException +logger = logging.getLogger(__name__) + # PostgreSQL settings PG_STATUS_RUNNING_DEFAULT = "running" PG_HBA_ROOT_DEFAULT = "/var/lib/pgsql/data" @@ -106,13 +109,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 @@ -129,19 +132,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
