Show More
@@ -35,6 +35,7 b' Config' | |||||
35 |
|
35 | |||
36 | [chgserver] |
|
36 | [chgserver] | |
37 | idletimeout = 3600 # seconds, after which an idle server will exit |
|
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 | from __future__ import absolute_import |
|
41 | from __future__ import absolute_import | |
@@ -516,6 +517,9 b' class _requesthandler(SocketServer.Strea' | |||||
516 | def _tempaddress(address): |
|
517 | def _tempaddress(address): | |
517 | return '%s.%d.tmp' % (address, os.getpid()) |
|
518 | return '%s.%d.tmp' % (address, os.getpid()) | |
518 |
|
519 | |||
|
520 | def _hashaddress(address, hashstr): | |||
|
521 | return '%s-%s' % (address, hashstr) | |||
|
522 | ||||
519 | class AutoExitMixIn: # use old-style to comply with SocketServer design |
|
523 | class AutoExitMixIn: # use old-style to comply with SocketServer design | |
520 | lastactive = time.time() |
|
524 | lastactive = time.time() | |
521 | idletimeout = 3600 # default 1 hour |
|
525 | idletimeout = 3600 # default 1 hour | |
@@ -581,6 +585,7 b' class chgunixservice(commandserver.unixs' | |||||
581 | # drop options set for "hg serve --cmdserver" command |
|
585 | # drop options set for "hg serve --cmdserver" command | |
582 | self.ui.setconfig('progress', 'assume-tty', None) |
|
586 | self.ui.setconfig('progress', 'assume-tty', None) | |
583 | signal.signal(signal.SIGHUP, self._reloadconfig) |
|
587 | signal.signal(signal.SIGHUP, self._reloadconfig) | |
|
588 | self._inithashstate() | |||
584 | class cls(AutoExitMixIn, SocketServer.ForkingMixIn, |
|
589 | class cls(AutoExitMixIn, SocketServer.ForkingMixIn, | |
585 | SocketServer.UnixStreamServer): |
|
590 | SocketServer.UnixStreamServer): | |
586 | ui = self.ui |
|
591 | ui = self.ui | |
@@ -589,9 +594,25 b' class chgunixservice(commandserver.unixs' | |||||
589 | self.server.idletimeout = self.ui.configint( |
|
594 | self.server.idletimeout = self.ui.configint( | |
590 | 'chgserver', 'idletimeout', self.server.idletimeout) |
|
595 | 'chgserver', 'idletimeout', self.server.idletimeout) | |
591 | self.server.startautoexitthread() |
|
596 | self.server.startautoexitthread() | |
|
597 | self._createsymlink() | |||
592 | # avoid writing "listening at" message to stdout before attachio |
|
598 | # avoid writing "listening at" message to stdout before attachio | |
593 | # request, which calls setvbuf() |
|
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 | def _reloadconfig(self, signum, frame): |
|
616 | def _reloadconfig(self, signum, frame): | |
596 | self.ui = self.server.ui = _renewui(self.ui) |
|
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