[PATCH] Input wanted on changes.
Bj|rn Augustsson <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb.dirstorage |
|---|---|
| Message-ID | <[email protected]> |
People,
I'm working on a setup where we need a highly available zeo server for
some zope sites, and I've got it working but I need some input on a
few choices I had to make. (I'm using linux and the heartbeat package)
I use replica.py, but I need it to run from the master (ie have the
master initiate the sync.)
We have several versions of zope running against these zeos (2.6.x and
2.7.x) and I couldn't find a good way to make replica.py work out
of the box, since
a) I can't set the PYTHONPATH in the zope users' login files, since
there are several versions of zope, and I don't know which one is
correct for the instance I'm replicating.
b) I _could_ do the .ssh/environment trick, sort of, but it would mean
* decide where the libs are for this instance
* ssh to the slave, update the zope users' .ssh/environment
* update the local zope users' .ssh/environment
* ssh to the slave again, run the script.
Apart from the fact that it you login interactively as zope, you'd
get an essentially random PYTONPATH, this is super ugly and fragile.
It would work, since all the instances gets replicated syncronously.
But if something breaks, all kinds of funky stuff could happen.
c) I tried adding a new option to replica.py (-p <dir-to-add-to-pythonpath>)
which would be passed along to the other side, but couldn't get it
to work without significant changes to the code.
(neophyte python hacker alert)
The way I have it installed, I just
cd /usr/local/zope/software/$ZOPE_VER/lib/python/
tar xvzf ~/src/DirectoryStorage_1_1_9.tgz
mv DirectoryStorage_1_1_9 DirectoryStorage
ln -s DirectoryStorage/DirectoryStorageToolkit
( cd DirectoryStorage && python2.3 compile.py )
So the ZODB modules it needs is in ".." from itself, and since it does
take the steps to find out where is it itself, I just moved that logic
up to before the module importing, and added
sys.path.append(os.path.dirname(mypath))
(See attached patch.)
Also, the same thing is needed for whatsnew.py.
(That patch also attached.)
Now, I'm not sure this is the Correct Solution (in fact I think it's a
bit of a hack), but I honestly can't figure out a better solution. (Except
option c above, but hey...) Any comments welcome.
Also, I added this to replica.py to avoid a lengthy timeout because the
zope user have no xauth info. (It could be done via ~/.ssh/config, but
since you never want it to be forwarded in the script, and you might
want it for an interactive session, I think this is better.)
cmd = [ sys.executable, os.path.join(mypath,'replica.py') ]
else:
cmd = [ self.ssh ]
+ cmd.append('-x')
if self.user:
cmd.extend( [ '-l', self.user ] )
cmd.extend ( [ self.rhost, self.rpython, os.path.join(self.ripath,"replica.py") ]
Thanks,
/August. (Please CC me, I only read the list via archives.)
--
Bj|rn Augustsson Sysadmin IT Systems & Services
Chalmers tekniska h|gskola Chalmers University of Technology
"Damn spooky analog crap." -- John Carmack.
replica-diff
(text/plain, 917 B)
--- DirectoryStorage_1_1_9/replica.py 2004-02-03 00:05:43.000000000 +0100
+++ replica.py-modded 2005-01-20 21:55:05.000000000 +0100
@@ -8,6 +8,15 @@
from __future__ import nested_scopes
import sys, getopt, os, time, string, stat, binascii, md5, binascii, tempfile, stat, traceback
+# path in which this script lives. We assume whatsnew.py is in the same place
+if __name__=='__main__':
+ mypath = sys.argv[0]
+else:
+ mypath = __file__
+mypath = os.path.split(os.path.abspath(mypath))[0]
+
+sys.path.append(os.path.dirname(mypath))
+
try:
import ZODB
except ImportError:
@@ -23,13 +32,6 @@
from PosixFilesystem import PosixFilesystem
from pipeline import pipeline
-# path in which this script lives. We assume whatsnew.py is in the same place
-if __name__=='__main__':
- mypath = sys.argv[0]
-else:
- mypath = __file__
-mypath = os.path.split(os.path.abspath(mypath))[0]
-
def main():
whatsnew-diff
(text/plain, 549 B)
--- DirectoryStorage_1_1_9/whatsnew.py 2003-01-30 19:03:40.000000000 +0100 +++ whatsnew-new.py 2005-01-21 13:12:28.000000000 +0100 @@ -1,5 +1,13 @@ import sys, getopt, os, time, string, stat, binascii, struct +if __name__=='__main__': + mypath = sys.argv[0] +else: + mypath = __file__ +mypath = os.path.split(os.path.abspath(mypath))[0] + +sys.path.append(os.path.dirname(mypath)) + from utils import oid2str, ConfigParser, tid2date from formats import formats