diff --git a/.nvmrc b/.nvmrc index 5a0afb48b..216afccff 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18.20.7 \ No newline at end of file +v18.20.7 diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index e396cfad9..7b2863fa2 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -40,18 +40,11 @@ done # set $1, $2, ... only with position arguments set -- "${POSITIONAL_ARGS[@]}" - -# check for missing branch name -if [ -z "$1" ]; then - echo "Usage: $0 [--fast] " - exit 1 -fi - BRANCH_NAME="$1" -# Debug-Ausgabe -if [ -z "$1" ]; then - echo "Usage: Please provide a branch name as the first argument." +# check for parameter +if [ -z "$BRANCH_NAME" ]; then + echo "Usage: $0 [--fast] [--fast]" exit 1 fi echo "Use branch: $BRANCH_NAME" @@ -69,9 +62,17 @@ PROJECT_ROOT=$SCRIPT_DIR/../.. NGINX_CONFIG_DIR=$SCRIPT_DIR/nginx/sites-available set +o allexport -# enable nvm +# enable nvm export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -nvm use +install_nvm() { + nvm install + nvm use + nvm alias default + npm i -g yarn pm2 + pm2 startup +} +# make sure correct node version is installed +nvm use || install_nvm # NOTE: all config values will be in process.env when starting # the services and will therefore take precedence over the .env @@ -144,22 +145,22 @@ sudo /etc/init.d/nginx restart # helper functions log_step() { local message="$1" - echo -e "\e[34m$message\e[0m" > /dev/tty # blue in console + echo -e "\e[34m$message\e[0m" # > /dev/tty # blue in console echo "

$message

" >> "$UPDATE_HTML" # blue in html } log_error() { local message="$1" - echo -e "\e[31m$message\e[0m" > /dev/tty # red in console + echo -e "\e[31m$message\e[0m" # > /dev/tty # red in console echo "$message" >> "$UPDATE_HTML" # red in html } log_warn() { local message="$1" - echo -e "\e[33m$message\e[0m" > /dev/tty # orange in console + echo -e "\e[33m$message\e[0m" # > /dev/tty # orange in console echo "$message" >> "$UPDATE_HTML" # orange in html } log_success() { local message="$1" - echo -e "\e[32m$message\e[0m" > /dev/tty # green in console + echo -e "\e[32m$message\e[0m" # > /dev/tty # green in console echo "

$message

" >> "$UPDATE_HTML" # green in html } @@ -168,9 +169,9 @@ log_success() { onError() { local exit_code=$? log_error "Command failed!" - log_error " /\\_/\\ Line: $LINENO" - log_error "( o.o ) Exit Code: $exit_code" - log_error " > ^ < Offending command: '$BASH_COMMAND'" + log_error " /\\_/\\ Line: $(caller 0)" + log_error "( x.x ) Exit Code: $exit_code" + log_error " > < Offending command: '$BASH_COMMAND'" log_error "" exit 1 } @@ -181,21 +182,19 @@ log_step "Stop and delete all Gradido services" # check if pm2 has processes, maybe it was already cleared from a failed update # pm2 delete all if pm2 has no processes will trigger error and stop script # so let's check first -if [ "$(pm2 prettylist)" != "[]" ]; then +if [ "$(echo "$(pm2 prettylist)" | tail -n 1)" != "[]" ]; then pm2 delete all pm2 save else log_warn "PM2 is already empty" fi - # git -BRANCH=$1 -log_step "Starting with git pull - branch:$BRANCH" +log_step "Starting with git pull - branch:$BRANCH_NAME" cd $PROJECT_ROOT # TODO: this overfetches alot, but ensures we can use start.sh with tags git fetch --all -git checkout $BRANCH +git checkout $BRANCH_NAME git pull export BUILD_COMMIT="$(git rev-parse HEAD)" @@ -307,7 +306,6 @@ else turbo up --env-mode=loose fi -nvm use default # start after building all to use up less ressources pm2 start --name gradido-backend "turbo backend#start --env-mode=loose" -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log --log-date-format 'YYYY-MM-DD 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' @@ -350,4 +348,6 @@ sudo /etc/init.d/nginx restart # keep the update log cat $UPDATE_HTML >> $GRADIDO_LOG_PATH/update.$TODAY.log -log_success 'Update finished' \ No newline at end of file +log_success " /\\_/\\ " +log_success "( ^.^ ) Update finished successfully!" +log_success " > <" diff --git a/deployment/hetzner_cloud/migration/2_5_1-2_5_2/README.md b/deployment/hetzner_cloud/migration/2_5_1-2_5_2/README.md deleted file mode 100644 index 7534ce060..000000000 --- a/deployment/hetzner_cloud/migration/2_5_1-2_5_2/README.md +++ /dev/null @@ -1,15 +0,0 @@ -## Migrate from Gradido Version 2.5.1 to 2.5.2 -### What -We need to upgrade the used nodejs version in deployment. Until now for pm2, backend, dht-node, federation nodejs 16 was used, -but some newer npm libs don't work with this old nodejs version so we upgrade to nodejs 18.20.7 - -### What you can do now -You need to only run this [upgradeNodeJs.sh](upgradeNodeJs.sh) with `release-2_5_2-beta` as parameter -```bash -cd /home/gradido/gradido/deployment/hetzner_cloud/migration/2_5_1-2_5_2 -sudo ./upgradeNodeJs.sh `release-2_5_2-beta` -``` - -It will stop pm2, install new nodejs version + pm2 + yarn, remove nodejs 16. -Then it will call start.sh with first parameter of ./upgradeNodeJs.sh as his first parameter - diff --git a/deployment/hetzner_cloud/migration/2_5_1-2_5_2/upgradeNodeJs.sh b/deployment/hetzner_cloud/migration/2_5_1-2_5_2/upgradeNodeJs.sh deleted file mode 100644 index baef7550d..000000000 --- a/deployment/hetzner_cloud/migration/2_5_1-2_5_2/upgradeNodeJs.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# check for parameter -if [ -z "$1" ]; then - echo "Usage: Please provide a branch name as the first argument." - exit 1 -fi - -# stop all services -pm2 delete all -pm2 save - -# upgrade node js version -nvm install 18.20.7 -nvm use 18.20.7 -nvm alias default 18.20.7 -npm install -g pm2 yarn -nvm uninstall 16 - -# Start gradido -sudo -u gradido $SCRIPT_PATH/start.sh $1 \ No newline at end of file