2017-01-11 12 views
0

redhatサーバのapache2の下でmod_wsgiでdjango(1.7.5)を使用し、ウォッチドッグを使ってファイルを監視しようとします。pythonウォッチドッグモジュールはredhatサーバの下でdjango/mod_wsgiと動作しません

私は、製品の環境へ

 
# wsgi.py 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

LOGGER.debug("Starting to watch for config file changes.") 
fw = FileWatcher() 
 
# filewatcher 
path = settings.PROJECT_ROOT 
filename = 'config.json' 
class ConfigHandler(FileSystemEventHandler): 
    def on_modified(self, event): 
     if not event.is_directory and event.src_path.endswith(filename): 
      LOGGER.debug("The config has changed!, Reloading") 

class FileWatcher(object): 

    _instance = None 
    _watching = False 

    def __new__(cls, *args, **kwargs): 
     if not cls._instance: 
      LOGGER.debug("Creating new FileWatcher") 
      cls._instance = super(FileWatcher, cls).__new__(cls, *args, **kwargs) 

      cls.start_watching() 

     return cls._instance 

    @classmethod 
    def start_watching(cls): 
     if not cls._watching: 
      LOGGER.debug("Starting to monitor the file: %s", 
         os.path.join(path, filename)) 
      event_handler = ConfigHandler() 
      observer = Observer() 
      observer.schedule(event_handler, path=path, recursive=False) 
      observer.start() 

      cls._watching = True 

答えて

0

それを展開するときに、イベントがWSGIモードでtriggerredされていないながらそれは、python manager.py runserverコマンドを使用してローカルで正常に動作しますが、デフォルトのオブザーバー(inotify.InotifyObserver)doesnのをルート原因を発見しました古いLinuxカーネルと古いRedHatのサーバー内の」トンの仕事は

それはhttp://pythonhosted.org/watchdog/api.html#module-watchdog.observers

に記載されています

そこで私は、一般的な1

 
    from watchdog.observers.polling import PollingObserver 
    # http://pythonhosted.org/watchdog/api.html#module-watchdog.observers 
    observer = PollingObserver() 
にそれを変更
関連する問題