From afb54b885bf1947caec2e01f234877710e50e682 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 12 Mar 2022 02:10:04 +0100 Subject: [PATCH 01/15] only rotate logfiles --- deployment/bare_metal/logrotate/gradido.conf.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/bare_metal/logrotate/gradido.conf.template b/deployment/bare_metal/logrotate/gradido.conf.template index c038f8e75..c543b54c2 100644 --- a/deployment/bare_metal/logrotate/gradido.conf.template +++ b/deployment/bare_metal/logrotate/gradido.conf.template @@ -1,4 +1,4 @@ -$GRADIDO_LOG_PATH/* { +$GRADIDO_LOG_PATH/*.log { weekly rotate 26 size 10M From 61e5ed287878d742f3960228507535ac4362f2ee Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 12 Mar 2022 02:47:45 +0100 Subject: [PATCH 02/15] date for log files save update log --- deployment/bare_metal/start.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 616e4b8ab..e82516dcc 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -42,9 +42,16 @@ if [ -f $LOCK_FILE ] ; then fi touch $LOCK_FILE +# find today string +TODAY=$(date +"%Y-%m-%d") + # Create a new updating.html from the template \cp $SCRIPT_DIR/nginx/update-page/updating.html.template $UPDATE_HTML +# redirect all output of the script to the UPDATE_HTML and also have things on console +# TODO: this might pose a security risk +exec 3>&1 1>>$UPDATE_HTML 2>&1 + # configure nginx for the update-page echo 'Configuring nginx to serve the update-page
' >> $UPDATE_HTML rm /etc/nginx/sites-enabled/gradido.conf @@ -113,7 +120,7 @@ yarn build # TODO maybe handle this differently? export NODE_ENV=production pm2 delete gradido-backend -pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GRADIDO_LOG_PATH/pm2.backend.log --log-date-format 'DD-MM HH:mm:ss.SSS' +pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log --log-date-format 'DD-MM HH:mm:ss.SSS' pm2 save # Install & build frontend @@ -126,7 +133,7 @@ yarn build # TODO maybe handle this differently? export NODE_ENV=production pm2 delete gradido-frontend -pm2 start --name gradido-frontend "yarn --cwd $PROJECT_ROOT/frontend start" -l $GRADIDO_LOG_PATH/pm2.frontend.log --log-date-format 'DD-MM HH:mm:ss.SSS' +pm2 start --name gradido-frontend "yarn --cwd $PROJECT_ROOT/frontend start" -l $GRADIDO_LOG_PATH/pm2.frontend.$TODAY.log --log-date-format 'DD-MM HH:mm:ss.SSS' pm2 save # Install & build admin @@ -139,7 +146,7 @@ yarn build # TODO maybe handle this differently? export NODE_ENV=production pm2 delete gradido-admin -pm2 start --name gradido-admin "yarn --cwd $PROJECT_ROOT/admin start" -l $GRADIDO_LOG_PATH/pm2.admin.log --log-date-format 'DD-MM HH:mm:ss.SSS' +pm2 start --name gradido-admin "yarn --cwd $PROJECT_ROOT/admin start" -l $GRADIDO_LOG_PATH/pm2.admin.$TODAY.log --log-date-format 'DD-MM HH:mm:ss.SSS' pm2 save # let nginx showing gradido @@ -148,5 +155,8 @@ ln -s /etc/nginx/sites-available/gradido.conf /etc/nginx/sites-enabled/ rm /etc/nginx/sites-enabled/update-page.conf sudo /etc/init.d/nginx restart +# keep the update log +cat $UPDATE_HTML >> $GRADIDO_LOG_PATH/update.$TODAY.log + # release lock rm $LOCK_FILE \ No newline at end of file From cf36ab72ee930e1d8998dfb20028a662f272b699 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 12 Mar 2022 02:55:27 +0100 Subject: [PATCH 03/15] fetch all for tag compatibility --- deployment/bare_metal/start.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index e82516dcc..9863bbc2a 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -66,7 +66,8 @@ pm2 stop all BRANCH=${1:-master} echo "Starting with git pull - branch:$BRANCH
" >> $UPDATE_HTML cd $PROJECT_ROOT -git fetch origin $BRANCH +# TODO: this overfetches alot, but ensures we can use start.sh with tags +git fetch origin --all git checkout $BRANCH git pull export BUILD_COMMIT="$(git rev-parse HEAD)" From b5ddd0359b9bcdfe1062683aec11f16787faa788 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 12 Mar 2022 03:03:16 +0100 Subject: [PATCH 04/15] use
 tag

---
 .../nginx/update-page/updating.html.template  |  6 +++---
 deployment/bare_metal/start.sh                | 20 +++++++++----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/deployment/bare_metal/nginx/update-page/updating.html.template b/deployment/bare_metal/nginx/update-page/updating.html.template
index a88a40b0f..356a9f139 100644
--- a/deployment/bare_metal/nginx/update-page/updating.html.template
+++ b/deployment/bare_metal/nginx/update-page/updating.html.template
@@ -1,3 +1,3 @@
-Gradido is currently updating...
-please stand by and try again in some minutes
-
\ No newline at end of file +
+Gradido is currently updating...
+please stand by and try again in some minutes
diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 9863bbc2a..ede5cab5d 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -53,18 +53,18 @@ TODAY=$(date +"%Y-%m-%d")
 exec 3>&1 1>>$UPDATE_HTML 2>&1
 
 # configure nginx for the update-page
-echo 'Configuring nginx to serve the update-page
' >> $UPDATE_HTML +echo 'Configuring nginx to serve the update-page' >> $UPDATE_HTML rm /etc/nginx/sites-enabled/gradido.conf ln -s /etc/nginx/sites-available/update-page.conf /etc/nginx/sites-enabled/ sudo /etc/init.d/nginx restart # stop all services -echo 'Stopping all Gradido services
' >> $UPDATE_HTML +echo 'Stopping all Gradido services' >> $UPDATE_HTML pm2 stop all # git BRANCH=${1:-master} -echo "Starting with git pull - branch:$BRANCH
" >> $UPDATE_HTML +echo "Starting with git pull - branch:$BRANCH" >> $UPDATE_HTML cd $PROJECT_ROOT # TODO: this overfetches alot, but ensures we can use start.sh with tags git fetch origin --all @@ -73,7 +73,7 @@ git pull export BUILD_COMMIT="$(git rev-parse HEAD)" # Generate gradido.conf from template -echo 'Generate new gradido nginx config
' >> $UPDATE_HTML +echo 'Generate new gradido nginx config' >> $UPDATE_HTML case "$NGINX_SSL" in true) TEMPLATE_FILE="gradido.conf.ssl.template" ;; *) TEMPLATE_FILE="gradido.conf.template" ;; @@ -81,7 +81,7 @@ esac envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $NGINX_CONFIG_DIR/$TEMPLATE_FILE > $NGINX_CONFIG_DIR/gradido.conf # Generate update-page.conf from template -echo 'Generate new update-page nginx config
' >> $UPDATE_HTML +echo 'Generate new update-page nginx config' >> $UPDATE_HTML case "$NGINX_SSL" in true) TEMPLATE_FILE="update-page.conf.ssl.template" ;; *) TEMPLATE_FILE="update-page.conf.template" ;; @@ -99,7 +99,7 @@ envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/frontend/.env envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/admin/.env.template > $PROJECT_ROOT/admin/.env # Install & build database -echo 'Updating database
' >> $UPDATE_HTML +echo 'Updating database' >> $UPDATE_HTML cd $PROJECT_ROOT/database yarn install yarn build @@ -112,7 +112,7 @@ else fi # Install & build backend -echo 'Updating backend
' >> $UPDATE_HTML +echo 'Updating backend' >> $UPDATE_HTML cd $PROJECT_ROOT/backend # TODO maybe handle this differently? unset NODE_ENV @@ -125,7 +125,7 @@ pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GR pm2 save # Install & build frontend -echo 'Updating frontend
' >> $UPDATE_HTML +echo 'Updating frontend' >> $UPDATE_HTML cd $PROJECT_ROOT/frontend # TODO maybe handle this differently? unset NODE_ENV @@ -138,7 +138,7 @@ pm2 start --name gradido-frontend "yarn --cwd $PROJECT_ROOT/frontend start" -l $ pm2 save # Install & build admin -echo 'Updating admin
' >> $UPDATE_HTML +echo 'Updating admin' >> $UPDATE_HTML cd $PROJECT_ROOT/admin # TODO maybe handle this differently? unset NODE_ENV @@ -151,7 +151,7 @@ pm2 start --name gradido-admin "yarn --cwd $PROJECT_ROOT/admin start" -l $GRADID pm2 save # let nginx showing gradido -echo 'Configuring nginx to serve gradido again
' >> $UPDATE_HTML +echo 'Configuring nginx to serve gradido again' >> $UPDATE_HTML ln -s /etc/nginx/sites-available/gradido.conf /etc/nginx/sites-enabled/ rm /etc/nginx/sites-enabled/update-page.conf sudo /etc/init.d/nginx restart From 6b2664e6ef4d234d2d1249498b9378f0379de5d9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 12 Mar 2022 03:05:36 +0100 Subject: [PATCH 05/15] add another newline --- deployment/bare_metal/nginx/update-page/updating.html.template | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/bare_metal/nginx/update-page/updating.html.template b/deployment/bare_metal/nginx/update-page/updating.html.template index 356a9f139..cc6d7debb 100644 --- a/deployment/bare_metal/nginx/update-page/updating.html.template +++ b/deployment/bare_metal/nginx/update-page/updating.html.template @@ -1,3 +1,4 @@
 Gradido is currently updating...
 please stand by and try again in some minutes
+

From 15219001b1130a53d82edc213600964ffaeeff5e Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Sat, 12 Mar 2022 03:08:45 +0100
Subject: [PATCH 06/15] try ussing tee for proper logoutput in console and file

---
 deployment/bare_metal/start.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index ede5cab5d..c6aadeb27 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -50,7 +50,8 @@ TODAY=$(date +"%Y-%m-%d")
 
 # redirect all output of the script to the UPDATE_HTML and also have things on console
 # TODO: this might pose a security risk
-exec 3>&1 1>>$UPDATE_HTML 2>&1
+# exec 3>&1 1>>$UPDATE_HTML 2>&1 
+exec > >(tee $UPDATE_HTML) 2>&1
 
 # configure nginx for the update-page
 echo 'Configuring nginx to serve the update-page' >> $UPDATE_HTML

From 0885938bdadf2db01519d9335f14cb51a768941b Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Sat, 12 Mar 2022 03:12:22 +0100
Subject: [PATCH 07/15] removed comment

---
 deployment/bare_metal/start.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index c6aadeb27..34e63a605 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -50,7 +50,6 @@ TODAY=$(date +"%Y-%m-%d")
 
 # redirect all output of the script to the UPDATE_HTML and also have things on console
 # TODO: this might pose a security risk
-# exec 3>&1 1>>$UPDATE_HTML 2>&1 
 exec > >(tee $UPDATE_HTML) 2>&1
 
 # configure nginx for the update-page

From 2975efe58f12de39e624958228ff0d6a8956d127 Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Sat, 12 Mar 2022 03:14:35 +0100
Subject: [PATCH 08/15] try appending to logfile with new method

---
 deployment/bare_metal/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 34e63a605..99b2c2947 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -50,7 +50,7 @@ TODAY=$(date +"%Y-%m-%d")
 
 # redirect all output of the script to the UPDATE_HTML and also have things on console
 # TODO: this might pose a security risk
-exec > >(tee $UPDATE_HTML) 2>&1
+exec > >>(tee $UPDATE_HTML) 2>&1
 
 # configure nginx for the update-page
 echo 'Configuring nginx to serve the update-page' >> $UPDATE_HTML

From 45068d512ceabfaa7d05576c9cadee71b8c617a2 Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Sat, 12 Mar 2022 03:17:46 +0100
Subject: [PATCH 09/15] tee append

---
 deployment/bare_metal/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 99b2c2947..6030899f0 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -50,7 +50,7 @@ TODAY=$(date +"%Y-%m-%d")
 
 # redirect all output of the script to the UPDATE_HTML and also have things on console
 # TODO: this might pose a security risk
-exec > >>(tee $UPDATE_HTML) 2>&1
+exec > >(tee -a $UPDATE_HTML) 2>&1
 
 # configure nginx for the update-page
 echo 'Configuring nginx to serve the update-page' >> $UPDATE_HTML

From 549f2182310eb1a2c704c3ff1a6ed4030df4143f Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Sat, 12 Mar 2022 03:52:01 +0100
Subject: [PATCH 10/15] module-aliases in order to have things working with
 `NODE_ENV=production`

---
 backend/src/index.ts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/backend/src/index.ts b/backend/src/index.ts
index 4c08b422d..7c6219c07 100644
--- a/backend/src/index.ts
+++ b/backend/src/index.ts
@@ -1,5 +1,8 @@
 /* eslint-disable @typescript-eslint/no-explicit-any */
 
+// resolve @-import-aliases
+import 'module-alias/register'
+
 import createServer from './server/createServer'
 
 // config

From 21848c2b1c1fbc4c6674891c8db8084679209458 Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Sat, 12 Mar 2022 04:06:03 +0100
Subject: [PATCH 11/15] reference build folders in moduleAliases

---
 backend/package.json | 10 +++++-----
 backend/src/index.ts |  3 ---
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/backend/package.json b/backend/package.json
index 710d73a8c..79e5fd130 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -60,12 +60,12 @@
     "typescript": "^4.3.4"
   },
   "_moduleAliases": {
-    "@": "./src",
-    "@arg": "./src/graphql/arg",
+    "@": "./build/src",
+    "@arg": "./build/src/graphql/arg",
     "@dbTools": "../database/build/src",
     "@entity": "../database/build/entity",
-    "@enum": "./src/graphql/enum",
-    "@model": "./src/graphql/model",
-    "@repository": "./src/typeorm/repository"
+    "@enum": "./build/src/graphql/enum",
+    "@model": "./build/src/graphql/model",
+    "@repository": "./build/src/typeorm/repository"
   }
 }
diff --git a/backend/src/index.ts b/backend/src/index.ts
index 7c6219c07..4c08b422d 100644
--- a/backend/src/index.ts
+++ b/backend/src/index.ts
@@ -1,8 +1,5 @@
 /* eslint-disable @typescript-eslint/no-explicit-any */
 
-// resolve @-import-aliases
-import 'module-alias/register'
-
 import createServer from './server/createServer'
 
 // config

From 3e25268c328bfac41fc1bd24378e2d5c9ec7b806 Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Mon, 14 Mar 2022 12:41:13 +0100
Subject: [PATCH 12/15] Update deployment/bare_metal/start.sh

Co-authored-by: Moriz Wahl 
---
 deployment/bare_metal/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 6030899f0..26e3f7e51 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -121,7 +121,7 @@ yarn build
 # TODO maybe handle this differently?
 export NODE_ENV=production
 pm2 delete gradido-backend
-pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log --log-date-format 'DD-MM HH:mm:ss.SSS'
+pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log --log-date-format 'YYYY-MM-DD:mm:ss.SSS'
 pm2 save
 
 # Install & build frontend

From 3a52a3892a1f5c00441ebc86a0604bede101ce4a Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Mon, 14 Mar 2022 12:41:19 +0100
Subject: [PATCH 13/15] Update deployment/bare_metal/start.sh

Co-authored-by: Moriz Wahl 
---
 deployment/bare_metal/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 26e3f7e51..3a8927fd2 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -147,7 +147,7 @@ yarn build
 # TODO maybe handle this differently?
 export NODE_ENV=production
 pm2 delete gradido-admin
-pm2 start --name gradido-admin "yarn --cwd $PROJECT_ROOT/admin start" -l $GRADIDO_LOG_PATH/pm2.admin.$TODAY.log --log-date-format 'DD-MM HH:mm:ss.SSS'
+pm2 start --name gradido-admin "yarn --cwd $PROJECT_ROOT/admin start" -l $GRADIDO_LOG_PATH/pm2.admin.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
 pm2 save
 
 # let nginx showing gradido

From e97bcd4d2036e31840b371150e0c62d3ea06ac3d Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Mon, 14 Mar 2022 12:41:25 +0100
Subject: [PATCH 14/15] Update deployment/bare_metal/start.sh

Co-authored-by: Moriz Wahl 
---
 deployment/bare_metal/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 3a8927fd2..6d979a79e 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -134,7 +134,7 @@ yarn build
 # TODO maybe handle this differently?
 export NODE_ENV=production
 pm2 delete gradido-frontend
-pm2 start --name gradido-frontend "yarn --cwd $PROJECT_ROOT/frontend start" -l $GRADIDO_LOG_PATH/pm2.frontend.$TODAY.log --log-date-format 'DD-MM HH:mm:ss.SSS'
+pm2 start --name gradido-frontend "yarn --cwd $PROJECT_ROOT/frontend start" -l $GRADIDO_LOG_PATH/pm2.frontend.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
 pm2 save
 
 # Install & build admin

From 1b1510a70f8f01f8bf979588b1f73971b1808f82 Mon Sep 17 00:00:00 2001
From: Ulf Gebhardt 
Date: Mon, 14 Mar 2022 15:00:37 +0100
Subject: [PATCH 15/15] Update deployment/bare_metal/start.sh

Co-authored-by: Moriz Wahl 
---
 deployment/bare_metal/start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh
index 6d979a79e..250971419 100755
--- a/deployment/bare_metal/start.sh
+++ b/deployment/bare_metal/start.sh
@@ -121,7 +121,7 @@ yarn build
 # TODO maybe handle this differently?
 export NODE_ENV=production
 pm2 delete gradido-backend
-pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log --log-date-format 'YYYY-MM-DD:mm:ss.SSS'
+pm2 start --name gradido-backend "yarn --cwd $PROJECT_ROOT/backend start" -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
 pm2 save
 
 # Install & build frontend