phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject [1/6] phoenix git commit: PHOENIX-4456 queryserver script doesn't perform as expected.
Date Wed, 13 Dec 2017 18:19:19 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 c4706109e -> 361c2da6a
  refs/heads/4.x-HBase-1.1 441539d1b -> 9d0a6bb7e
  refs/heads/4.x-HBase-1.2 f93443c5d -> 1625dd620
  refs/heads/4.x-cdh5.11.2 c49de1c5f -> bea0592c2
  refs/heads/5.x-HBase-2.0 a54fd4aa6 -> 5019be449
  refs/heads/master 1a19d1ecb -> 90c724161


PHOENIX-4456 queryserver script doesn't perform as expected.


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

Branch: refs/heads/5.x-HBase-2.0
Commit: 5019be449d3431b71e8245688369fa90a6bf4a82
Parents: a54fd4a
Author: Sergey Soldatov <ssa@apache.org>
Authored: Tue Dec 12 23:20:48 2017 -0800
Committer: Sergey Soldatov <ssa@apache.org>
Committed: Wed Dec 13 10:15:36 2017 -0800

----------------------------------------------------------------------
 bin/daemon.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/5019be44/bin/daemon.py
----------------------------------------------------------------------
diff --git a/bin/daemon.py b/bin/daemon.py
index aeebae3..bb64148 100644
--- a/bin/daemon.py
+++ b/bin/daemon.py
@@ -57,6 +57,7 @@ import signal
 import socket
 import atexit
 import fcntl
+import time
 try:
     # Python 2 has both ‘str’ (bytes) and ‘unicode’ (text).
     basestring = basestring
@@ -386,7 +387,7 @@ class DaemonContext:
         change_process_owner(self.uid, self.gid)
 
         if self.detach_process:
-            detach_process_context()
+            detach_process_context(self.pidfile)
 
         signal_handler_map = self._make_signal_handler_map()
         set_signal_handlers(signal_handler_map)
@@ -657,7 +658,7 @@ def prevent_core_dump():
     resource.setrlimit(core_resource, core_limit)
 
 
-def detach_process_context():
+def detach_process_context(pidfile):
     """ Detach the process context from parent and session.
 
         :return: ``None``.
@@ -683,6 +684,8 @@ def detach_process_context():
         try:
             pid = os.fork()
             if pid > 0:
+                while not os.path.exists(pidfile.path):
+                    time.sleep(0.1)
                 os._exit(0)
         except OSError as exc:
             error = DaemonProcessDetachError(
@@ -959,7 +962,14 @@ found at [1].
     def __init__(self, path, enter_err_msg=None):
         self.path = path
         self.enter_err_msg = enter_err_msg
-        self.pidfile = None
+        self.pidfile = open(self.path, 'a+')
+        try:
+            fcntl.flock(self.pidfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
+            fcntl.flock(self.pidfile.fileno(), fcntl.LOCK_UN)
+            self.pidfile.close()
+            os.remove(self.path)
+        except IOError:
+            sys.exit(self.enter_err_msg)
 
     def __enter__(self):
         self.pidfile = open(self.path, 'a+')


Mime
View raw message