update deployment scripts

This commit is contained in:
HF 2023-12-13 03:53:16 +01:00
parent 1304dfb4ba
commit fb87a18bd7
2 changed files with 22 additions and 63 deletions

View File

@ -1,15 +1,13 @@
#!/bin/bash
# This hook builds pixelplanet after a push, and deploys it, it should be ron post-receive
# 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)
# This hook builds pixelplanet after a push to a development branch,
# and starts the dev-canvas
#
# 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"
#folder for dev canvas
DEVFOLDER="/home/pixelpla/pixelplanet-dev"
#folder for production canvas
PFOLDER="/home/pixelpla/pixelplanet"
should_reinstall () {
local TMPFILE="${BUILDDIR}/package.json.${1}.tmp"
@ -33,12 +31,12 @@ npm_reinstall () {
copy () {
local TARGETDIR="${1}"
local REINSTALL="${2}"
cp -r dist/*.js "${TARGETDIR}/"
cp -r dist/workers "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/*.js "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/workers "${TARGETDIR}/"
rm -rf "${TARGETDIR}/public/assets"
cp -r dist/public "${TARGETDIR}/"
cp -r dist/captchaFonts "${TARGETDIR}/"
cp -r dist/package.json "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/public "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/captchaFonts "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/package.json "${TARGETDIR}/"
mkdir -p "${TARGETDIR}/log"
cd "${TARGETDIR}"
[ $REINSTALL -eq 0 ] && npm_reinstall
@ -51,28 +49,10 @@ do
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
cd "$BUILDDIR"
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$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
if [ "test" == "$branch" ] || [ "devel" == "$branch" ]; then
echo "---UPDATING REPO ON DEV SERVER---"
pm2 stop ppfun-server-dev
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 dev
DO_REINSTALL=$?

View File

@ -1,18 +1,10 @@
#!/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)
BUILDDIR="/home/pixelpla/pixelplanet-build"
#folder for dev canvas
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
PFOLDER="/home/pixelpla/pixelplanet"
#which branch to use
@ -40,21 +32,20 @@ npm_reinstall () {
copy () {
local TARGETDIR="${1}"
local REINSTALL="${2}"
cp -r dist/*.js "${TARGETDIR}/"
cp -r dist/workers "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/*.js "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/workers "${TARGETDIR}/"
rm -rf "${TARGETDIR}/public/assets"
cp -r dist/public "${TARGETDIR}/"
cp -r dist/captchaFonts "${TARGETDIR}/"
cp -r dist/package.json "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/public "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/captchaFonts "${TARGETDIR}/"
cp -r "${BUILDDIR}"/dist/package.json "${TARGETDIR}/"
mkdir -p "${TARGETDIR}/log"
cd "${TARGETDIR}"
[ $REINSTALL -eq 0 ] && npm_reinstall
pm2 start ecosystem.yml
[ ${REINSTALL} -eq 0 ] && npm_reinstall
cd -
}
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
cd "$BUILDDIR"
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all
echo "---UPDATING REPO ON PRODUCTION SERVER---"
GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git reset --hard "origin/${BRANCH}"
echo "---BUILDING pixelplanet---"
@ -63,22 +54,10 @@ DO_REINSTALL=$?
[ $DO_REINSTALL -eq 0 ] && npm_reinstall
npm run build
echo "---RESTARTING CANVAS---"
pm2 stop ppfun-server
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
cp dist/canvases.json ~/
cd "$PFOLDER"
pm2 stop ppfun-backups
pm2 stop ecosystem.config.js
copy "${PFOLDER}" "${DO_REINSTALL}"
pm2 start ecosystem-backup.yml
pm2 start ecosystem.config.js