Gulp watch is very frustrating because it dies quickly and some plugins can't catch exceptions. So I wrote a Python script that will revive like a zombie as soon as it dies
zombie.py
#!/usr/bin/env python
# -*- codint: utf-8 -*-
import sys
import signal
import subprocess
def rite(silent):
print("start rite of gulp watch be zombie")
print("if you want stop this program, Ctrl+C")
cmd = "gulp watch"
while True:
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(p.stdout.readline, b''):
print(line.rstrip())
if not silent:
print("\a")
print("\ngulp watch is dead. but revive soon.\n")
def signalHandler(signal, frame):
print("\ngulp zombie killed")
sys.exit(0)
if __name__ == '__main__':
signal.signal(signal.SIGINT, signalHandler)
try:
sys.argv.index("-s")
rite(True)
except ValueError:
rite(False)
Put this in the same place as gulpfile.js
python zombie.py
If so, even if the gulp watch dies, it will be revived like a zombie. By the way, it usually sounds like a beep, but
python zombie.py -s
If you do, you can also be quiet. You can also kill this zombie with Ctrl + C as you would with a normal command. Gist
Recommended Posts