Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 02537e999 -> 8d7951e2e


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/8d7951e2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8d7951e2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8d7951e2

Branch: refs/heads/branch-2.2
Commit: 8d7951e2ea6e0d6d38a2aac90f53086c1cae407b
Parents: 02537e9
Author: Dmytro Sen <d...@apache.org>
Authored: Tue Dec 22 16:34:30 2015 +0200
Committer: Dmytro Sen <d...@apache.org>
Committed: Tue Dec 22 16:38:34 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/8d7951e2/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 76e86ee..89283fb 100644
--- a/ambari-server/src/main/python/ambari_server_main.py
+++ b/ambari-server/src/main/python/ambari_server_main.py
@@ -268,8 +268,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:
@@ -283,13 +294,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

Reply via email to