update deployment scripts
This commit is contained in:
parent
1304dfb4ba
commit
fb87a18bd7
|
@ -1,15 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This hook builds pixelplanet after a push, and deploys it, it should be ron post-receive
|
# This hook builds pixelplanet after a push to a development branch,
|
||||||
# If it is the master branch, it will deploy it on the life system, and other branch will get deployed to the dev-canvas (a second canvas that is running on the server)
|
# and starts the dev-canvas
|
||||||
#
|
#
|
||||||
# To set up a server to use this, you have to go through the building steps manually first.
|
# To set up a server to use this, you have to go through the building steps manually first.
|
||||||
#
|
#
|
||||||
#folder for building the canvas (the git repository will get checkout there and the canvas will get buil thtere)
|
#folder for building the canvas (the git repository will get checkout there and the canvas will get built thtere)
|
||||||
BUILDDIR="/home/pixelpla/pixelplanet-build"
|
BUILDDIR="/home/pixelpla/pixelplanet-build"
|
||||||
#folder for dev canvas
|
#folder for dev canvas
|
||||||
DEVFOLDER="/home/pixelpla/pixelplanet-dev"
|
DEVFOLDER="/home/pixelpla/pixelplanet-dev"
|
||||||
#folder for production canvas
|
|
||||||
PFOLDER="/home/pixelpla/pixelplanet"
|
|
||||||
|
|
||||||
should_reinstall () {
|
should_reinstall () {
|
||||||
local TMPFILE="${BUILDDIR}/package.json.${1}.tmp"
|
local TMPFILE="${BUILDDIR}/package.json.${1}.tmp"
|
||||||
|
@ -33,12 +31,12 @@ npm_reinstall () {
|
||||||
copy () {
|
copy () {
|
||||||
local TARGETDIR="${1}"
|
local TARGETDIR="${1}"
|
||||||
local REINSTALL="${2}"
|
local REINSTALL="${2}"
|
||||||
cp -r dist/*.js "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/*.js "${TARGETDIR}/"
|
||||||
cp -r dist/workers "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/workers "${TARGETDIR}/"
|
||||||
rm -rf "${TARGETDIR}/public/assets"
|
rm -rf "${TARGETDIR}/public/assets"
|
||||||
cp -r dist/public "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/public "${TARGETDIR}/"
|
||||||
cp -r dist/captchaFonts "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/captchaFonts "${TARGETDIR}/"
|
||||||
cp -r dist/package.json "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/package.json "${TARGETDIR}/"
|
||||||
mkdir -p "${TARGETDIR}/log"
|
mkdir -p "${TARGETDIR}/log"
|
||||||
cd "${TARGETDIR}"
|
cd "${TARGETDIR}"
|
||||||
[ $REINSTALL -eq 0 ] && npm_reinstall
|
[ $REINSTALL -eq 0 ] && npm_reinstall
|
||||||
|
@ -51,28 +49,10 @@ do
|
||||||
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
|
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
|
||||||
cd "$BUILDDIR"
|
cd "$BUILDDIR"
|
||||||
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
|
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
|
||||||
if [ "master" == "$branch" ]; then
|
if [ "test" == "$branch" ] || [ "devel" == "$branch" ]; then
|
||||||
echo "---UPDATING REPO ON PRODUCTION SERVER---"
|
|
||||||
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git reset --hard "origin/$branch"
|
|
||||||
COMMITS=`git log --pretty=format:'- %s%b' $newrev ^$oldrev`
|
|
||||||
COMMITS=`echo "$COMMITS" | sed ':a;N;$!ba;s/\n/\\\n/g'`
|
|
||||||
echo "---BUILDING pixelplanet---"
|
|
||||||
should_reinstall master
|
|
||||||
DO_REINSTALL=$?
|
|
||||||
[ $DO_REINSTALL -eq 0 ] && npm_reinstall
|
|
||||||
npm run build
|
|
||||||
echo "---RESTARTING CANVAS---"
|
|
||||||
pm2 stop ppfun-server
|
|
||||||
pm2 stop ppfun-backups
|
|
||||||
copy "${PFOLDER}" "${DO_REINSTALL}"
|
|
||||||
cd "$PFOLDER"
|
|
||||||
pm2 start ecosystem-backup.yml
|
|
||||||
else
|
|
||||||
echo "---UPDATING REPO ON DEV SERVER---"
|
echo "---UPDATING REPO ON DEV SERVER---"
|
||||||
pm2 stop ppfun-server-dev
|
pm2 stop ppfun-server-dev
|
||||||
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git reset --hard "origin/$branch"
|
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git reset --hard "origin/$branch"
|
||||||
COMMITS=`git log --pretty=format:'- %s%b' $newrev ^$oldrev`
|
|
||||||
COMMITS=`echo "$COMMITS" | sed ':a;N;$!ba;s/\n/\\\n/g'`
|
|
||||||
echo "---BUILDING pixelplanet---"
|
echo "---BUILDING pixelplanet---"
|
||||||
should_reinstall dev
|
should_reinstall dev
|
||||||
DO_REINSTALL=$?
|
DO_REINSTALL=$?
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Rebuild from master branch and restart pixelplanet
|
# Rebuild and Restert pixelplanet
|
||||||
|
|
||||||
#folder for building the canvas (the git repository will get checkout there and the canvas will get buil thtere)
|
#folder for building the canvas (the git repository will get checkout there and the canvas will get buil thtere)
|
||||||
BUILDDIR="/home/pixelpla/pixelplanet-build"
|
BUILDDIR="/home/pixelpla/pixelplanet-build"
|
||||||
#folder for dev canvas
|
#folder for dev canvas
|
||||||
DEVFOLDER="/home/pixelpla/pixelplanet-dev"
|
DEVFOLDER="/home/pixelpla/pixelplanet-dev"
|
||||||
#folder for shards
|
|
||||||
SCBFOLDER="/home/pixelpla/pixelplanet-scb"
|
|
||||||
SCCFOLDER="/home/pixelpla/pixelplanet-scc"
|
|
||||||
SCDFOLDER="/home/pixelpla/pixelplanet-scd"
|
|
||||||
SCEFOLDER="/home/pixelpla/pixelplanet-sce"
|
|
||||||
SCFFOLDER="/home/pixelpla/pixelplanet-scf"
|
|
||||||
SCGFOLDER="/home/pixelpla/pixelplanet-scg"
|
|
||||||
SCHFOLDER="/home/pixelpla/pixelplanet-sch"
|
|
||||||
#folder for production canvas
|
#folder for production canvas
|
||||||
PFOLDER="/home/pixelpla/pixelplanet"
|
PFOLDER="/home/pixelpla/pixelplanet"
|
||||||
#which branch to use
|
#which branch to use
|
||||||
|
@ -40,21 +32,20 @@ npm_reinstall () {
|
||||||
copy () {
|
copy () {
|
||||||
local TARGETDIR="${1}"
|
local TARGETDIR="${1}"
|
||||||
local REINSTALL="${2}"
|
local REINSTALL="${2}"
|
||||||
cp -r dist/*.js "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/*.js "${TARGETDIR}/"
|
||||||
cp -r dist/workers "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/workers "${TARGETDIR}/"
|
||||||
rm -rf "${TARGETDIR}/public/assets"
|
rm -rf "${TARGETDIR}/public/assets"
|
||||||
cp -r dist/public "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/public "${TARGETDIR}/"
|
||||||
cp -r dist/captchaFonts "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/captchaFonts "${TARGETDIR}/"
|
||||||
cp -r dist/package.json "${TARGETDIR}/"
|
cp -r "${BUILDDIR}"/dist/package.json "${TARGETDIR}/"
|
||||||
mkdir -p "${TARGETDIR}/log"
|
mkdir -p "${TARGETDIR}/log"
|
||||||
cd "${TARGETDIR}"
|
cd "${TARGETDIR}"
|
||||||
[ $REINSTALL -eq 0 ] && npm_reinstall
|
[ ${REINSTALL} -eq 0 ] && npm_reinstall
|
||||||
pm2 start ecosystem.yml
|
|
||||||
cd -
|
cd -
|
||||||
}
|
}
|
||||||
|
|
||||||
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
|
|
||||||
cd "$BUILDDIR"
|
cd "$BUILDDIR"
|
||||||
|
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
|
||||||
echo "---UPDATING REPO ON PRODUCTION SERVER---"
|
echo "---UPDATING REPO ON PRODUCTION SERVER---"
|
||||||
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git reset --hard "origin/${BRANCH}"
|
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git reset --hard "origin/${BRANCH}"
|
||||||
echo "---BUILDING pixelplanet---"
|
echo "---BUILDING pixelplanet---"
|
||||||
|
@ -63,22 +54,10 @@ DO_REINSTALL=$?
|
||||||
[ $DO_REINSTALL -eq 0 ] && npm_reinstall
|
[ $DO_REINSTALL -eq 0 ] && npm_reinstall
|
||||||
npm run build
|
npm run build
|
||||||
echo "---RESTARTING CANVAS---"
|
echo "---RESTARTING CANVAS---"
|
||||||
pm2 stop ppfun-server
|
cp dist/canvases.json ~/
|
||||||
pm2 stop ppfun-backups
|
|
||||||
pm2 stop ppfun-scb
|
|
||||||
pm2 stop ppfun-scc
|
|
||||||
pm2 stop ppfun-scd
|
|
||||||
pm2 stop ppfun-sce
|
|
||||||
pm2 stop ppfun-scf
|
|
||||||
pm2 stop ppfun-scg
|
|
||||||
pm2 stop ppfun-sch
|
|
||||||
copy "${PFOLDER}" "${DO_REINSTALL}"
|
|
||||||
copy "${SCBFOLDER}" 1
|
|
||||||
copy "${SCCFOLDER}" 1
|
|
||||||
copy "${SCDFOLDER}" 1
|
|
||||||
copy "${SCEFOLDER}" 1
|
|
||||||
copy "${SCFFOLDER}" 1
|
|
||||||
copy "${SCGFOLDER}" 1
|
|
||||||
copy "${SCHFOLDER}" 1
|
|
||||||
cd "$PFOLDER"
|
cd "$PFOLDER"
|
||||||
|
pm2 stop ppfun-backups
|
||||||
|
pm2 stop ecosystem.config.js
|
||||||
|
copy "${PFOLDER}" "${DO_REINSTALL}"
|
||||||
pm2 start ecosystem-backup.yml
|
pm2 start ecosystem-backup.yml
|
||||||
|
pm2 start ecosystem.config.js
|
||||||
|
|
Loading…
Reference in New Issue
Block a user