7yhwaq
Last Updated: February 25, 2016
·
1.237K
· liorkesos
8667c0cb4e8519b3ef1e67111641ca33

mean.io startup script (ubuntu)

Most of the info for mean is development focused.
This is the startup script we use for production environments...

# /etc/init/nodejs-linnovate-il.conf
description 'node meanlean system startup'
author 'adpated from ivarprudnikov.com'
env NAME=SAMOBILE
env LOG_FILE=/var/log/nodejs-meanlean.log
env USER=www-data
env NODE_BIN=/usr/local/bin/node
env NODE_ENV="production"
env SCRIPT_FILE=/var/www/meanlean/server.js
start on runlevel [23]
stop on shutdown
# Respawn in case of a crash, with default parameters
respawn
script
  cd /var/www/meanlean
  su www-data -s /bin/bash
  # Make sure logfile exists and can be written by the user we drop privileges to
  touch $LOG_FILE
  chown $USER:$USER $LOG_FILE
  # recommended approach in case of su/sudo usage so that service does not fork
  exec sudo -u $USER NODE_ENV="production" PORT=8006 $NODE_BIN $SCRIPT_FILE >> $LOG_FILE 2>&1
end script
post-start script
  echo "app $NAME post-start event" >> $LOG_FILE
end script
Say Thanks
Respond

1 Response
Add your response

15898

Don't think this script solves the problem of aggregation. We want to ideally deploy the app with a load balancer using nginx, but are struggling a little.

over 1 year ago ·