pghoard icon indicating copy to clipboard operation
pghoard copied to clipboard

OS X Support

Open loganb opened this issue 7 years ago • 3 comments

Hello,

I'm trying to use pghoard on OS X and it barfs on startup:

2018-01-14 21:11:29,959	pghoard	MainThread	DEBUG	Loading JSON config from: 'pghoard.json', signal: None
Traceback (most recent call last):
  File "/usr/local/bin/pghoard", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/pghoard/pghoard.py", line 573, in main
    pghoard = PGHoard(config_path)
  File "/usr/local/lib/python3.6/site-packages/pghoard/pghoard.py", line 79, in __init__
    self.inotify = InotifyWatcher(self.compression_queue)
  File "/usr/local/lib/python3.6/site-packages/pghoard/rohmu/inotify.py", line 58, in __init__
    self.libc = ctypes.CDLL("libc.so.6", use_errno=True)
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libc.so.6, 6): image not found

It looks like you're trying to directly load libc to use Linux's inotify APIs. Obviously that won't work on OS X. I'm not a pythonista so this question may be naive, but have you considered swapping out this custom code with a cross-platform library, like https://pypi.python.org/pypi/watchdog?

loganb avatar Jan 15 '18 05:01 loganb

inotify support is currently needed for the pg_receivexlog/pg_receivewal based wal archiving. You should be able to use archive_command based archiving on OS X pretty easily by adding some checks around inotifywatcher initialization.

We don't currently have plans for changing inotify functionality, but it might make more sense to parse the output of pg_receivexlog to see when it's done writing a file instead of adding another filesystem watcher. Also, there's a beta-level implementation for direct WAL streaming from PG without using pg_receivexlog at all that should do away with requirements for watching filesystem events.

saaros avatar Jan 15 '18 15:01 saaros

Got it, that makes sense. So if I’m reading this right, pghoard can’t start on OS X because it attempts to load libc and initialize inotify in a constructor on startup.

What do you think is the best way to factor that out of the startup path?

loganb avatar Jan 15 '18 15:01 loganb

As the only thing using the inotify mechanism is PGReceiveXLog the initialization should be moved closer to it, there's no point in running the thread if you're not using the receivexlog mode.

Ormod avatar Jan 18 '18 12:01 Ormod