NodeJS bash start script (default environment variable)

?
S
Bash

Useful snippet to set a fallback environment variable when starting a NodeJS Express app (or similar)

1#!/bin/bash
2
3if [ -z "$NODE_ENV" ]; then
4    export NODE_ENV=development
5fi
6
7cd /var/www/coderecipes
8
9pm2 start -x bin/www --name="coderecipes" --no-daemon --watch
10

Created on 1/25/2018