Show More
@@ -25,6 +25,9 | |||||
25 | 'setumask' command |
|
25 | 'setumask' command | |
26 | set umask |
|
26 | set umask | |
27 |
|
27 | |||
|
28 | 'validate' command | |||
|
29 | reload the config and check if the server is up to date | |||
|
30 | ||||
28 | 'SIGHUP' signal |
|
31 | 'SIGHUP' signal | |
29 | reload configuration files |
|
32 | reload configuration files | |
30 |
|
33 | |||
@@ -341,6 +344,9 class chgcmdserver(commandserver.server) | |||||
341 | self._oldios = [] # original (self.ch, ui.fp, fd) before "attachio" |
|
344 | self._oldios = [] # original (self.ch, ui.fp, fd) before "attachio" | |
342 | self.hashstate = hashstate |
|
345 | self.hashstate = hashstate | |
343 | self.baseaddress = baseaddress |
|
346 | self.baseaddress = baseaddress | |
|
347 | if hashstate is not None: | |||
|
348 | self.capabilities = self.capabilities.copy() | |||
|
349 | self.capabilities['validate'] = chgcmdserver.validate | |||
344 |
|
350 | |||
345 | def cleanup(self): |
|
351 | def cleanup(self): | |
346 | # dispatch._runcatch() does not flush outputs if exception is not |
|
352 | # dispatch._runcatch() does not flush outputs if exception is not | |
@@ -413,6 +419,31 class chgcmdserver(commandserver.server) | |||||
413 | setattr(ui, fn, fp) |
|
419 | setattr(ui, fn, fp) | |
414 | del self._oldios[:] |
|
420 | del self._oldios[:] | |
415 |
|
421 | |||
|
422 | def validate(self): | |||
|
423 | """Reload the config and check if the server is up to date | |||
|
424 | ||||
|
425 | Read a list of '\0' separated arguments. | |||
|
426 | Write a non-empty list of '\0' separated instruction strings or '\0' | |||
|
427 | if the list is empty. | |||
|
428 | An instruction string could be either: | |||
|
429 | - "unlink $path", the client should unlink the path to stop the | |||
|
430 | outdated server. | |||
|
431 | - "redirect $path", the client should try to connect to another | |||
|
432 | server instead. | |||
|
433 | """ | |||
|
434 | args = self._readlist() | |||
|
435 | self.ui = _renewui(self.ui, args) | |||
|
436 | newhash = hashstate.fromui(self.ui, self.hashstate.mtimepaths) | |||
|
437 | insts = [] | |||
|
438 | if newhash.mtimehash != self.hashstate.mtimehash: | |||
|
439 | addr = _hashaddress(self.baseaddress, self.hashstate.confighash) | |||
|
440 | insts.append('unlink %s' % addr) | |||
|
441 | if newhash.confighash != self.hashstate.confighash: | |||
|
442 | addr = _hashaddress(self.baseaddress, newhash.confighash) | |||
|
443 | insts.append('redirect %s' % addr) | |||
|
444 | _log('validate: %s\n' % insts) | |||
|
445 | self.cresult.write('\0'.join(insts) or '\0') | |||
|
446 | ||||
416 | def chdir(self): |
|
447 | def chdir(self): | |
417 | """Change current directory |
|
448 | """Change current directory | |
418 |
|
449 |
General Comments 0
You need to be logged in to leave comments.
Login now