diff options
Diffstat (limited to 'geo-replication')
| -rw-r--r-- | geo-replication/syncdaemon/gsyncd.py | 3 | ||||
| -rw-r--r-- | geo-replication/syncdaemon/gsyncdstatus.py | 17 | 
2 files changed, 18 insertions, 2 deletions
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py index 32e4eb7828d..b3c7e62506e 100644 --- a/geo-replication/syncdaemon/gsyncd.py +++ b/geo-replication/syncdaemon/gsyncd.py @@ -615,7 +615,8 @@ def main_i():      status_get = rconf.get('status_get')      if status_get:          for brick in gconf.path: -            brick_status = GeorepStatus(gconf.state_file, brick) +            brick_status = GeorepStatus(gconf.state_file, brick, +                                        getattr(gconf, "pid_file", None))              checkpoint_time = int(getattr(gconf, "checkpoint", "0"))              brick_status.print_status(checkpoint_time=checkpoint_time)          return diff --git a/geo-replication/syncdaemon/gsyncdstatus.py b/geo-replication/syncdaemon/gsyncdstatus.py index 57692f8fab0..77f3f9e7569 100644 --- a/geo-replication/syncdaemon/gsyncdstatus.py +++ b/geo-replication/syncdaemon/gsyncdstatus.py @@ -16,6 +16,7 @@ import urllib  import json  import time  from datetime import datetime +from errno import EACCES, EAGAIN  DEFAULT_STATUS = "N/A"  MONITOR_STATUS = ("Created", "Started", "Paused", "Stopped") @@ -113,7 +114,7 @@ def set_monitor_status(status_file, status):  class GeorepStatus(object): -    def __init__(self, monitor_status_file, brick): +    def __init__(self, monitor_status_file, brick, monitor_pid_file=None):          self.work_dir = os.path.dirname(monitor_status_file)          self.monitor_status_file = monitor_status_file          self.filename = os.path.join(self.work_dir, @@ -126,6 +127,7 @@ class GeorepStatus(object):          os.close(fd)          self.brick = brick          self.default_values = get_default_values() +        self.monitor_pid_file = monitor_pid_file      def _update(self, mergerfunc):          with LockedOpen(self.filename, 'r+') as f: @@ -254,6 +256,19 @@ class GeorepStatus(object):                  pass          monitor_status = self.get_monitor_status() +        # Verifying whether monitor process running and adjusting status +        if monitor_status in ["Started", "Paused"]: +            try: +                with open(self.monitor_pid_file, "r+") as f: +                    fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) +                    monitor_status = "Stopped" +            except (IOError, OSError) as e: +                if e.errno in (EACCES, EAGAIN): +                    # cannot grab. so, monitor process still running..move on +                    pass +                else: +                    raise +          if monitor_status in ["Created", "Paused", "Stopped"]:              data["worker_status"] = monitor_status  | 
