diff libervia/server/server.py @ 1153:94f9d81a475e

pages: auto reloading when developer mode is activated, pages are automatically reloaded when page_meta.py is modified.
author Goffi <goffi@goffi.org>
date Fri, 22 Feb 2019 16:57:37 +0100
parents 1c23252958ed
children fb4b4da61132
line wrap: on
line diff
--- a/libervia/server/server.py	Fri Feb 22 16:57:37 2019 +0100
+++ b/libervia/server/server.py	Fri Feb 22 16:57:37 2019 +0100
@@ -1878,11 +1878,16 @@
 
         # we create virtual hosts and import Libervia pages into them
         self.vhost_root = vhost.NameVirtualHost()
-        default_site_path = os.path.dirname(libervia.__file__)
+        default_site_path = os.path.abspath(os.path.dirname(libervia.__file__))
         # self.sat_root is official Libervia site
         self.sat_root = default_root = LiberviaRootResource(
             host=self, host_name=u'', site_name=u'', site_path=default_site_path,
             path=self.html_dir)
+        if self.options['dev_mode']:
+            self.files_watcher.watchDir(
+                default_site_path, auto_add=True, recursive=True,
+                callback=LiberviaPage.onFileChange, site_root=self.sat_root,
+                site_path=default_site_path)
         tasks_manager = TasksManager(self, self.sat_root)
         yield tasks_manager.runTasks()
         LiberviaPage.importPages(self, self.sat_root)
@@ -1916,6 +1921,12 @@
                     site_name=site_name,
                     site_path=site_path,
                     path=root_path)
+
+                if self.options['dev_mode']:
+                    self.files_watcher.watchDir(
+                        site_path, auto_add=True, recursive=True,
+                        callback=LiberviaPage.onFileChange, site_root=res,
+                        site_path=site_path)
                 tasks_manager = TasksManager(self, res)
                 yield tasks_manager.runTasks()
                 res.putChild(C.BUILD_DIR, static.File(self.getBuildPath(site_name)))