live-server startup script to be installed in /etc/init.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# May 2018 | |
# removed iptables and just run directly on port 443 | |
# added RNT_ENV | |
# | |
# | |
# read in wishtrip config file for value of RNT_ENV etc | |
# | |
RNT_CONFIG_FILE=/etc/rnt.conf | |
if [ -s $RNT_CONFIG_FILE ]; then | |
. $RNT_CONFIG_FILE | |
fi | |
# test $RNT_ENV | |
[ -z "$RNT_ENV" ] && (echo >&2 "Variable is unset"; logger -t wishtrip "$0: RNT_ENV is unset, aborting";exit 1) | |
# for Live | |
case $RNT_ENV in | |
prd) | |
NODE_ENV=PROD | |
;; | |
stg) | |
NODE_ENV=STAGING | |
;; | |
*) | |
# default | |
NODE_ENV=$RNT_ENV | |
;; | |
esac | |
#echo "RNT_ENV IS $RNT_ENV" | |
#echo "NODE_ENV IS $NODE_ENV" | |
# set variables for Live server | |
export NODE_ENV | |
export PORT=443 | |
export DEBUG=*,-express*,-socket*,-engine*,-compression,-ioredis*,-send,-node-stringprep,-body-parser:*,-morgan | |
SERVER_DIR=/opt/webservers/live-server | |
case "$1" in | |
start) | |
#logger "Configuring iptables " | |
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443 | |
logger "Running live server with forever" | |
exec forever --sourceDir=$SERVER_DIR -l /var/log/forever.log -a -o /var/log/live-out.log -e /var/log/live-err.log start bin/www | |
;; | |
stop) | |
logger "Stopping live server" | |
#iptables -t nat -F | |
#iptables -t nat -X | |
uid=$(forever list | grep bin/www | cut -c24-27) | |
exec forever stop $uid | |
;; | |
restart) | |
#iptables -t nat -F | |
#iptables -t nat -X | |
uid=$(forever list | grep bin/www | cut -c24-27) | |
exec forever stop $uid | |
#logger "Configuring iptables " | |
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443 | |
logger "Running live server with forever" | |
exec forever --sourceDir=$SERVER_DIR -l /var/log/forever.log -a -o /var/log/live-out.log -e /var/log/live-err.log start bin/www | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment