Initial commit of content.
This commit is contained in:
2
deployment/.gitignore
vendored
Normal file
2
deployment/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
settings
|
||||
settings.production
|
||||
9
deployment/README
Normal file
9
deployment/README
Normal file
@@ -0,0 +1,9 @@
|
||||
This is a deployment folder for use with Stagecoach.
|
||||
|
||||
You don't have to use Stagecoach.
|
||||
|
||||
It's just a neat solution for deploying node apps.
|
||||
|
||||
See:
|
||||
|
||||
https://github.com/apostrophecms/stagecoach
|
||||
48
deployment/dependencies
Normal file
48
deployment/dependencies
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Also a good place to ensure any data folders
|
||||
# that are *not* supposed to be replaced on every deployment exist
|
||||
# and create a symlink to them from the latest deployment directory.
|
||||
|
||||
# The real 'data' folder is shared. It lives two levels up and one over
|
||||
# (we're in a deployment dir, which is a subdir of 'deployments', which
|
||||
# is a subdir of the project's main dir)
|
||||
|
||||
HERE=`pwd`
|
||||
mkdir -p ../data
|
||||
ln -s ../data $HERE/data
|
||||
|
||||
# We also have a shared uploads folder which is convenient to keep
|
||||
# in a separate place so we don't have to have two express.static calls
|
||||
|
||||
mkdir -p ../uploads
|
||||
ln -s ../uploads $HERE/public/uploads
|
||||
|
||||
# Install any dependencies that can't just be rsynced over with
|
||||
# the deployment. Example: node apps have npm modules in a
|
||||
# node_modules folder. These may contain compiled C++ code that
|
||||
# won't work portably from one server to another.
|
||||
|
||||
# This script runs after the rsync, but before the 'stop' script,
|
||||
# so your app is not down during the npm installation.
|
||||
|
||||
# Make sure node_modules exists so npm doesn't go searching
|
||||
# up the filesystem tree
|
||||
mkdir -p node_modules
|
||||
|
||||
# If there is no package.json file then we don't need npm install
|
||||
if [ -f './package.json' ]; then
|
||||
# Install npm modules
|
||||
# Use a suitable version of Python
|
||||
# export PYTHON=/usr/bin/python26
|
||||
npm install
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error during npm install!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
node app apostrophe-migrations:migrate --safe
|
||||
# Generate new static asset files for this
|
||||
# deployment of the app without shutting down
|
||||
node app apostrophe:generation
|
||||
8
deployment/migrate
Normal file
8
deployment/migrate
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run any necessary database migration tasks that should happen while the
|
||||
# site is paused here.
|
||||
|
||||
node app apostrophe-migrations:migrate
|
||||
|
||||
echo "Site migrated"
|
||||
14
deployment/rsync_exclude.txt
Normal file
14
deployment/rsync_exclude.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
# List files and folders that shouldn't be deployed (such as data folders and runtime status files) here.
|
||||
# In our projects .git and .gitignore are good candidates, also 'data' which contains persistent files
|
||||
# that are *not* part of deployment. A good place for things like data/port, data/pid, and any
|
||||
# sqlite databases or static web content you may need
|
||||
data
|
||||
temp
|
||||
public/uploads
|
||||
public/modules
|
||||
public/apos-minified
|
||||
.git
|
||||
.gitignore
|
||||
# We don't deploy these anymore, instead we always 'npm install' to ensure
|
||||
# that any compiled C++ modules are built for the right architecture
|
||||
node_modules
|
||||
22
deployment/settings.example
Normal file
22
deployment/settings.example
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Settings shared by all targets (staging, production, etc). Usually the
|
||||
# shortname of the project (which is also the hostname for the frontend
|
||||
# proxy server used for staging sites) and the directory name. For our
|
||||
# web apps that use sc-proxy we make sure each is a subdirectory
|
||||
# of /opt/stagecoach/apps
|
||||
|
||||
PROJECT=apostrophe
|
||||
DIR=/opt/stagecoach/apps/$PROJECT
|
||||
|
||||
# Adjust the PATH environment variable on the remote host. Here's an example
|
||||
# for deploying to MacPorts
|
||||
#ADJUST_PATH='export PATH=/opt/local/bin:$PATH'
|
||||
|
||||
# ... But you probably won't need to on real servers. I just find it handy for
|
||||
# testing parts of stagecoach locally on a Mac. : is an acceptable "no-op" (do-nothing) statement
|
||||
ADJUST_PATH=':'
|
||||
|
||||
# ssh port. Sensible people leave this set to 22 but it's common to do the
|
||||
# "security by obscurity" thing alas
|
||||
SSH_PORT=22
|
||||
10
deployment/settings.production.example
Normal file
10
deployment/settings.production.example
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Settings specific to the 'master' deployment target.
|
||||
# USER is the ssh user, SERVER is the ssh host. USER should
|
||||
# match the USER setting in /opt/stagecoach/settings on
|
||||
# the server
|
||||
|
||||
USER=myuser
|
||||
SERVER=myserver.com
|
||||
|
||||
63
deployment/start
Normal file
63
deployment/start
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
|
||||
# Express should not reveal information on errors,
|
||||
# also optimizes Express performance
|
||||
export NODE_ENV=production
|
||||
|
||||
if [ ! -f "app.js" ]; then
|
||||
echo "I don't see app.js in the current directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Assign a port number if we don't yet have one
|
||||
|
||||
if [ -f "data/port" ]; then
|
||||
PORT=`cat data/port`
|
||||
else
|
||||
# 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"
|
||||
PORT=3000
|
||||
else
|
||||
# Bash is much nicer than sh! We can do math without tears!
|
||||
let PORT+=1
|
||||
fi
|
||||
echo $PORT > data/port
|
||||
echo "First startup, chose port $PORT for this site"
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# Use a "for" loop. A classic single-port file will do the
|
||||
# right thing, but so will a file with multiple port numbers
|
||||
# for load balancing across multiple cores
|
||||
for port in $PORT
|
||||
do
|
||||
export PORT=$port
|
||||
forever --minUptime=1000 --spinSleepTime=10000 -o data/console.log -e data/error.log start `pwd`/app.js && echo "Site started"
|
||||
done
|
||||
|
||||
# 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 app.js >> data/console.log 2>&1 &
|
||||
# PID=$!
|
||||
# echo $PID > data/pid
|
||||
#
|
||||
#echo "Site started"
|
||||
27
deployment/stop
Normal file
27
deployment/stop
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Shut the site down, for instance by tweaking a .htaccess file to display
|
||||
# a 'please wait' notice, or stopping a node server
|
||||
|
||||
if [ ! -f "app.js" ]; then
|
||||
echo "I don't see app.js in the current directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop the node app via 'forever'. You'll get a harmless warning if the app
|
||||
# was not already running. 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 stop `pwd`/app.js && echo "Site stopped"
|
||||
|
||||
# Stop the app without 'forever'. We recommend using 'forever' for node apps,
|
||||
# but this may be your best bet for non-node apps
|
||||
#
|
||||
# if [ -f "data/pid" ]; then
|
||||
# kill `cat data/pid`
|
||||
# rm data/pid
|
||||
# echo "Site stopped"
|
||||
# else
|
||||
# echo "Site was not running"
|
||||
# fi
|
||||
|
||||
Reference in New Issue
Block a user