changeset 1368:9624c2a89a92

server: new `--build-only` flag: when this flag is set, the HTTP server is not launched, and Libervia quits immediately after running building tasks.
author Goffi <goffi@goffi.org>
date Fri, 20 Nov 2020 18:04:05 +0100
parents ce5cfe004d4e
children b5f2565c4bac
files libervia/server/server.py twisted/plugins/libervia_server.py
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/server.py	Fri Nov 20 18:02:43 2020 +0100
+++ b/libervia/server/server.py	Fri Nov 20 18:04:05 2020 +0100
@@ -1571,10 +1571,17 @@
             reactor.stop()
             return failure
 
+    def _buildOnlyCb(self, __):
+        log.info(_("Stopping here due to --build-only flag"))
+        self.stop()
+
     def startService(self):
         """Connect the profile for Libervia and start the HTTP(S) server(s)"""
         self._init()
-        self.initialised.addCallback(self._startService)
+        if self.options['build-only']:
+            self.initialised.addCallback(self._buildOnlyCb)
+        else:
+            self.initialised.addCallback(self._startService)
         self.initialised.addErrback(self.initEb)
 
     ## URLs ##
--- a/twisted/plugins/libervia_server.py	Fri Nov 20 18:02:43 2020 +0100
+++ b/twisted/plugins/libervia_server.py	Fri Nov 20 18:04:05 2020 +0100
@@ -148,6 +148,7 @@
 
 # Flags are in command line only
 OPT_FLAGS = [
+    ['build-only', 'B', _("Only build website, don't run the server")],
     ['dev-mode', 'D', _('Developer mode, automatically reload modified pages')],
 ]