Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 05fee2b546
Fetching contributors…

Cannot retrieve contributors at this time

52 lines (44 sloc) 1.75 KB
# Make the site live again, for instance by tweaking a .htaccess file
# or starting a node server. In this example we also set up a
# data/port file so that sc-proxy.js can figure out what port
# to forward traffic to for this site. The idea is that every
# folder in /var/webapps represents a separate project with a separate
# node process, each listening on a specific port, and they all
# need traffic forwarded from a reverse proxy server on port 80
# Useful for debugging
#set -x verbose
if [ ! -f "server.js" ]; then
echo "I don't see server.js in the current directory."
exit 1
# Assign a port number if we don't yet have one
if [ -f "data/port" ]; then
PORT=`cat data/port`
# No port set yet for this site. Scan and sort the existing port numbers if any,
# grab the highest existing one
PORT=`cat ../../../*/data/port 2>/dev/null | sort -n | tail -1`
if [ "$PORT" == "" ]; then
echo "First app ever, assigning port 3000"
# Bash is much nicer than sh! We can do math without tears!
let PORT+=1
echo $PORT > data/port
echo "First startup, chose port $PORT for this site"
# Run the app via 'forever' so that it restarts automatically if it fails
# Use `pwd` to make sure we have a full path, forever is otherwise easily confused
# and will stop every server with the same filename
forever --minUptime 1000 --spinSleepTime 5000 -o data/console.log -e data/error.log start `pwd`/server.js && echo "Site started"
# Run the app without 'forever'. Record the process id so 'stop' can kill it later.
# We recommend installing 'forever' instead for node apps. For non-node apps this code
# may be helpful
# node server.js >> data/console.log 2>&1 &
# PID=$!
# echo $PID > data/pid
#echo "Site started"
Jump to Line
Something went wrong with that request. Please try again.