[serverct] call server_{maintenance,shutdown} hooks around source-sync command
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 07 Jul 2015 14:13:10 +0200
changeset 10526 459d6f24754b
parent 10525 b8fddae83a46
child 10527 2379f136d48c
[serverct] call server_{maintenance,shutdown} hooks around source-sync command
server/serverctl.py
--- a/server/serverctl.py	Tue Jul 07 14:12:46 2015 +0200
+++ b/server/serverctl.py	Tue Jul 07 14:13:10 2015 +0200
@@ -991,12 +991,16 @@
         config.log_format = '%(levelname)s %(name)s: %(message)s'
         init_cmdline_log_threshold(config, self['loglevel'])
         repo = repoapi.get_repository(config=config)
+        repo.hm.call_hooks('server_maintenance', repo=repo)
         try:
-            source = repo.sources_by_uri[args[1]]
-        except KeyError:
-            raise ExecutionError('no source named %r' % args[1])
-        with repo.internal_cnx() as cnx:
-            stats = source.pull_data(cnx, force=True, raise_on_error=True)
+            try:
+                source = repo.sources_by_uri[args[1]]
+            except KeyError:
+                raise ExecutionError('no source named %r' % args[1])
+            with repo.internal_cnx() as cnx:
+                stats = source.pull_data(cnx, force=True, raise_on_error=True)
+        finally:
+            repo.shutdown()
         for key, val in stats.iteritems():
             if val:
                 print key, ':', val