ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [34/51] [abbrv] ambari git commit: AMBARI-14466 warning setpgid failed issued when starting ambari server (dsen)
Date Wed, 23 Dec 2015 15:07:13 GMT
AMBARI-14466 warning setpgid failed issued when starting ambari server (dsen)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: ff4e90e4d76060f1143bcf9efca09e857e367e2a
Parents: a8238e0
Author: Dmytro Sen <dsen@apache.org>
Authored: Tue Dec 22 16:34:30 2015 +0200
Committer: Dmytro Sen <dsen@apache.org>
Committed: Tue Dec 22 16:34:30 2015 +0200

----------------------------------------------------------------------
 .../src/main/python/ambari_server_main.py       | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ff4e90e4/ambari-server/src/main/python/ambari_server_main.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server_main.py b/ambari-server/src/main/python/ambari_server_main.py
index e9bdec3..cf8e8c0 100644
--- a/ambari-server/src/main/python/ambari_server_main.py
+++ b/ambari-server/src/main/python/ambari_server_main.py
@@ -275,8 +275,19 @@ def server_process_main(options, scmStatus=None):
   if not os.path.exists(configDefaults.PID_DIR):
     os.makedirs(configDefaults.PID_DIR, 0755)
 
+  # The launched shell process and sub-processes should have a group id that
+  # is different from the parent.
+  def make_process_independent():
+    processId = os.getpid()
+    if processId > 0:
+      try:
+        os.setpgid(processId, processId)
+      except OSError, e:
+        print_warning_msg('setpgid({0}, {0}) failed - {1}'.format(pidJava, str(e)))
+        pass
+
   print_info_msg("Running server: " + str(param_list))
-  procJava = subprocess.Popen(param_list, env=environ)
+  procJava = subprocess.Popen(param_list, env=environ, preexec_fn=make_process_independent)
 
   pidJava = procJava.pid
   if pidJava <= 0:
@@ -290,13 +301,6 @@ def server_process_main(options, scmStatus=None):
 
     raise FatalException(-1, AMBARI_SERVER_DIE_MSG.format(exitcode, configDefaults.SERVER_OUT_FILE))
   else:
-    # Change the group id to the process id of the parent so that the launched
-    # process and sub-processes have a group id that is different from the parent.
-    try:
-      os.setpgid(pidJava, 0)
-    except OSError, e:
-      print_warning_msg('setpgid({0}, 0) failed - {1}'.format(pidJava, str(e)))
-      pass
     pidfile = os.path.join(configDefaults.PID_DIR, PID_NAME)
     save_pid(pidJava, pidfile)
     print "Server PID at: "+pidfile


Mime
View raw message