comparison hgext/chgserver.py @ 28454:8062869860b8

chg: remove manual reload logic chgserver now validates and reloads configs automatically. Manually reloading is no longer necessary. Besides, we are deprecating pid files since the server will periodically check its ownership of the socket file and exit if it does not own the socket file any longer, which works more reliable than a pid file. This patch removes the SIGHUP reload logic from both chg server and client.
author Jun Wu <quark@fb.com>
date Thu, 10 Mar 2016 00:12:33 +0000
parents 8f9661d1637b
children e6e183687545
comparison
equal deleted inserted replaced
28453:8a7110e351ec 28454:8062869860b8
26 set umask 26 set umask
27 27
28 'validate' command 28 'validate' command
29 reload the config and check if the server is up to date 29 reload the config and check if the server is up to date
30 30
31 'SIGHUP' signal
32 reload configuration files
33
34 Config 31 Config
35 ------ 32 ------
36 33
37 :: 34 ::
38 35
46 import SocketServer 43 import SocketServer
47 import errno 44 import errno
48 import inspect 45 import inspect
49 import os 46 import os
50 import re 47 import re
51 import signal
52 import struct 48 import struct
53 import sys 49 import sys
54 import threading 50 import threading
55 import time 51 import time
56 import traceback 52 import traceback
614 if exc.errno != errno.ENOENT: 610 if exc.errno != errno.ENOENT:
615 raise 611 raise
616 612
617 class chgunixservice(commandserver.unixservice): 613 class chgunixservice(commandserver.unixservice):
618 def init(self): 614 def init(self):
619 signal.signal(signal.SIGHUP, self._reloadconfig)
620 self._inithashstate() 615 self._inithashstate()
621 class cls(AutoExitMixIn, SocketServer.ForkingMixIn, 616 class cls(AutoExitMixIn, SocketServer.ForkingMixIn,
622 SocketServer.UnixStreamServer): 617 SocketServer.UnixStreamServer):
623 ui = self.ui 618 ui = self.ui
624 repo = self.repo 619 repo = self.repo
645 return 640 return
646 tempaddress = _tempaddress(self.baseaddress) 641 tempaddress = _tempaddress(self.baseaddress)
647 os.symlink(os.path.basename(self.address), tempaddress) 642 os.symlink(os.path.basename(self.address), tempaddress)
648 util.rename(tempaddress, self.baseaddress) 643 util.rename(tempaddress, self.baseaddress)
649 644
650 def _reloadconfig(self, signum, frame):
651 self.ui = self.server.ui = _renewui(self.ui)
652
653 def run(self): 645 def run(self):
654 try: 646 try:
655 self.server.serve_forever() 647 self.server.serve_forever()
656 finally: 648 finally:
657 self.server.unlinksocketfile() 649 self.server.unlinksocketfile()