diff --git a/CHANGELOG.md b/CHANGELOG.md index 28d9f09ba7be0499d54b5051f374763f034af913..121201b677541d5b6ab08c8dc74fd03fd8240aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ changed functionality, fixed bugs). ## Version 2.0.6 (in development) - Fixed incompatibility with attrs version 17.1+. +- Added `--reregister` CLI option to re-register this worker at its Manager. + WARNING: this can cause duplicate worker information in the Manager's database. ## Version 2.0.5 (released 2017-05-09) diff --git a/flamenco_worker/cli.py b/flamenco_worker/cli.py index c9ec21f922b2d56aae56543fd0a5ff4a9bcb652c..52bca805c1143f3996c869dae232933e56fb8311 100644 --- a/flamenco_worker/cli.py +++ b/flamenco_worker/cli.py @@ -16,6 +16,10 @@ def main(): parser.add_argument('-v', '--verbose', action='store_true', help='Show configuration before starting, ' 'and asyncio task status at shutdown.') + parser.add_argument('-r', '--reregister', action='store_true', + help="Erases authentication information and re-registers this worker " + "at the Manager. WARNING: this can cause duplicate worker information " + "in the Manager's database.") args = parser.parse_args() # Load configuration @@ -26,6 +30,11 @@ def main(): log = logging.getLogger(__name__) log.debug('Starting') + if args.reregister: + log.warning('Erasing worker_id and worker_secret so we can attempt re-registration.') + confparser.erase('worker_id') + confparser.erase('worker_secret') + # Patch AsyncIO from . import patch_asyncio patch_asyncio.patch_asyncio() diff --git a/flamenco_worker/config.py b/flamenco_worker/config.py index 2e9ac2b37e51bccdecce7f8c31b2d23942a5f2e8..411db829461e5d7ec6ca671fc35791be29108cfb 100644 --- a/flamenco_worker/config.py +++ b/flamenco_worker/config.py @@ -45,6 +45,9 @@ class ConfigParser(configparser.ConfigParser): secs = self.value(key, float) return datetime.timedelta(seconds=secs) + def erase(self, key: str) -> bool: + return self.set(CONFIG_SECTION, key, '') + def merge_with_home_config(new_conf: dict): """Updates the home configuration file with the given config dict."""