##// END OF EJS Templates
chgserver: mangle server address to include confighash...
Jun Wu -
r28326:ea400a4f default
parent child Browse files
Show More
@@ -35,6 +35,7 b' Config'
35 35
36 36 [chgserver]
37 37 idletimeout = 3600 # seconds, after which an idle server will exit
38 skiphash = False # whether to skip config or env change checks
38 39 """
39 40
40 41 from __future__ import absolute_import
@@ -516,6 +517,9 b' class _requesthandler(SocketServer.Strea'
516 517 def _tempaddress(address):
517 518 return '%s.%d.tmp' % (address, os.getpid())
518 519
520 def _hashaddress(address, hashstr):
521 return '%s-%s' % (address, hashstr)
522
519 523 class AutoExitMixIn: # use old-style to comply with SocketServer design
520 524 lastactive = time.time()
521 525 idletimeout = 3600 # default 1 hour
@@ -581,6 +585,7 b' class chgunixservice(commandserver.unixs'
581 585 # drop options set for "hg serve --cmdserver" command
582 586 self.ui.setconfig('progress', 'assume-tty', None)
583 587 signal.signal(signal.SIGHUP, self._reloadconfig)
588 self._inithashstate()
584 589 class cls(AutoExitMixIn, SocketServer.ForkingMixIn,
585 590 SocketServer.UnixStreamServer):
586 591 ui = self.ui
@@ -589,9 +594,25 b' class chgunixservice(commandserver.unixs'
589 594 self.server.idletimeout = self.ui.configint(
590 595 'chgserver', 'idletimeout', self.server.idletimeout)
591 596 self.server.startautoexitthread()
597 self._createsymlink()
592 598 # avoid writing "listening at" message to stdout before attachio
593 599 # request, which calls setvbuf()
594 600
601 def _inithashstate(self):
602 self.baseaddress = self.address
603 if self.ui.configbool('chgserver', 'skiphash', False):
604 self.hashstate = None
605 return
606 self.hashstate = hashstate.fromui(self.ui)
607 self.address = _hashaddress(self.address, self.hashstate.confighash)
608
609 def _createsymlink(self):
610 if self.baseaddress == self.address:
611 return
612 tempaddress = _tempaddress(self.baseaddress)
613 os.symlink(self.address, tempaddress)
614 util.rename(tempaddress, self.baseaddress)
615
595 616 def _reloadconfig(self, signum, frame):
596 617 self.ui = self.server.ui = _renewui(self.ui)
597 618
General Comments 0
You need to be logged in to leave comments. Login now