feat: added copying static
This commit is contained in:
@@ -6,13 +6,14 @@ import os
|
||||
import subprocess
|
||||
|
||||
from .config import SOURCE_DIRECTORY, CODE_DIRECTORY
|
||||
from .build import build as complete_build
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger("stsg")
|
||||
|
||||
|
||||
def build():
|
||||
print("building changed")
|
||||
complete_build()
|
||||
|
||||
|
||||
class MarkdownChangeHandler(FileSystemEventHandler):
|
||||
@@ -26,10 +27,12 @@ class MarkdownChangeHandler(FileSystemEventHandler):
|
||||
|
||||
logger.info("%s changed, building", event.src_path)
|
||||
build()
|
||||
|
||||
|
||||
|
||||
class PythonChangeHandler(FileSystemEventHandler):
|
||||
def __init__(self, command):
|
||||
self.logger = logging.getLogger("stsg.hot_reload")
|
||||
|
||||
self.env = os.environ.copy()
|
||||
self.env["IS_CHILD"] = "true"
|
||||
|
||||
@@ -37,11 +40,11 @@ class PythonChangeHandler(FileSystemEventHandler):
|
||||
self.process = self.start_process()
|
||||
|
||||
def start_process(self):
|
||||
print("[hot reload] Starting process...")
|
||||
self.logger.info("Starting process...")
|
||||
return subprocess.Popen(self.command, env=self.env)
|
||||
|
||||
def restart_process(self):
|
||||
print("[hot reload] Restarting process...")
|
||||
self.logger.info("Restarting process...")
|
||||
self.process.kill()
|
||||
self.process = self.start_process()
|
||||
|
||||
@@ -54,7 +57,7 @@ class PythonChangeHandler(FileSystemEventHandler):
|
||||
return
|
||||
|
||||
if event.src_path.endswith(".py"):
|
||||
print(f"[hot reload] Detected change: {event.src_path}")
|
||||
self.logger.info(f"Detected change: {event.src_path}")
|
||||
self.restart_process()
|
||||
|
||||
def stop_process(self):
|
||||
@@ -84,7 +87,7 @@ def hot_reload():
|
||||
return
|
||||
|
||||
observer = Observer()
|
||||
observer.schedule(PythonChangeHandler(["stsg_build_on_change"]), path=CODE_DIRECTORY, recursive=True)
|
||||
observer.schedule(PythonChangeHandler(["stsg_dev"]), path=CODE_DIRECTORY, recursive=True)
|
||||
observer.start()
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user