server-spawn
(
)When the development server boots up it emits this event if plugins want to spawn their own development tools. For instance it can be used to start a background process that kicks off webpack or similar tools. There is a second event called server-stop which can be used to detect server shutdowns.
import os
from subprocess import Popen
class MyPlugin(Plugin):
...
webpack = None
def on_server_spawn(self, **extra):
path = os.path.join(self.env.root_path, 'webpack')
self.webpack = Popen(['webpack', '--watch'], cwd=path)
def on_server_stop(self, **extra):
if self.webpack is not None:
self.webpack.kill()
A list of some plugins that make use of this event is available here.
Comments