DEV Community

Discussion on: Blue/Green Node.js Deploys with NGINX

Collapse
 
edgarbonet profile image
Edgar Bonet

Thanks for this very instructive article! Here are a couple of bash tricks you may use to slightly simplify your scripts:

  • Instead of using a retry loop, the random numbers can be generated with
  echo $((floor + RANDOM % (range - floor + 1)))
  • A very old trick used to avoid grepping-out grep:
  grep "[n]ginx: worker process"

But note that you may be able to avoid grep if you can ask ps to display only the relevant processes. On Ubuntu, you may select the process that are owned by www-data:

echo $(ps --no-header -u www-data | wc -l)