简体   繁体   中英

how to determine if gulp watch is running

I run gulp on server in background running

gulp &

but sometimes it fail down. So mi question is: Is there some command for gulp to ask if is running. Something like

gulp status

Thanks

There is nothing special in gulp to limit running multiple processes or alert you to an already running gulp process.

Use regular Unix techniques to check if a process is running. Use a supervisor like supervisord or runit to automatically restart processes.

#the program pidof will set the variable $? to either
#1 or 0 in bash depending on if it finds a process
#with that name.  It will also print out all the matching
#process IDs to the command line
pidof gulp
echo $?  #1 if there is no process called gulp
         #0 if there is a process called gulp
if pidof gulp; then 
   echo 'gulp is alive';
else
   echo 'we need some support over here!'
   ./node_modules/.bin/gulp watch &
   sleep 3
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM