Created
March 29, 2014 13:21
-
-
Save jpadilla/9854405 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import atexit | |
import signal | |
from django.conf import settings | |
from django_extensions.management.commands.runserver_plus import Command\ | |
as StaticfilesRunserverCommand | |
class Command(StaticfilesRunserverCommand): | |
def inner_run(self, *args, **options): | |
self.start_brunch() | |
return super(Command, self).inner_run(*args, **options) | |
def start_brunch(self): | |
self.stdout.write('--> Starting brunch') | |
self.brunch_process = subprocess.Popen( | |
['cd {0} && brunch watch --server'.format(settings.BRUNCH_DIR)], | |
shell=True, | |
stdin=subprocess.PIPE, | |
stdout=self.stdout, | |
stderr=self.stderr, | |
) | |
self.stdout.write('--> Brunch process on pid {0}'.format(self.brunch_process.pid)) | |
def kill_brunch_process(pid): | |
self.stdout.write('--> Closing brunch process') | |
os.kill(pid, signal.SIGTERM) | |
atexit.register(kill_brunch_process, self.brunch_process.pid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment