<commit_before>#!/bin/bash

rtfblog_proj="../rtfblog"

killall rtfblog
pushd $rtfblog_proj
make all
popd

suffix="-staging"
goose_env="staging"

if [ "$1" == "prod" ]; then
    suffix=""
    goose_env="production"
fi

package=./package
cp -r $rtfblog_proj/build $package
rm $package/server.conf
rm $package/server.log
cp -r $rtfblog_proj/db $package
cp ./stuff/images/* $package/static/
cp ./testdata/rtfblog-dump.sql $package/rtfblog-dump.sql
go build ./cmd/migrate-db/
cp ./migrate-db $package
tar czvf package.tar.gz ./package
rm -rf $package

scp -q scripts/unpack.sh <EMAIL>:/home/rtfb/unpack.sh
scp -q package.tar.gz <EMAIL>:/home/rtfb/package.tar.gz
rm ./package.tar.gz
full_path=/home/rtfb/package$suffix
pid=$(ssh <EMAIL> "pidof $full_path/rtfblog")
ssh <EMAIL> "kill $pid"
ssh <EMAIL> "/home/rtfb/unpack.sh package$suffix"
ssh <EMAIL> "rm $full_path/db/dbconf.yml"
ssh <EMAIL> "ln -s /home/rtfb/rtfblog-dbconf.yml $full_path/db/dbconf.yml"
ssh <EMAIL> "$full_path/migrate-db --db=$full_path/db --env=$goose_env"
ssh <EMAIL> "nohup $full_path/rtfblog </dev/null 1>&2&> $full_path/nohup.log &"<commit_msg>deploy: several catchups and improvements<commit_after>#!/bin/bash

env="staging"
suffix="-$env"

if [ "$1" == "prod" ]; then
    env="production"
    suffix=""
fi

goose_env=$env
echo "Deploying $env..."

rtfblog_proj="../rtfblog"

killall rtfblog
pushd $rtfblog_proj
make all
popd

package=./package
cp -r $rtfblog_proj/build $package
rm $package/server.conf
rm $package/server.log
cp -r $rtfblog_proj/db $package
cp ./stuff/images/* $package/static/
cp ./testdata/rtfblog-dump.sql $package/rtfblog-dump.sql
go build ./cmd/migrate-db/
cp ./migrate-db $package
tar czvf package.tar.gz ./package
rm -rf $package

scp -q scripts/unpack.sh <EMAIL>:/home/rtfb/unpack.sh
scp -q package.tar.gz <EMAIL>:/home/rtfb/package.tar.gz
rm ./package.tar.gz
full_path=/home/rtfb/package$suffix
ssh <EMAIL> "service rtfblog stop"
ssh <EMAIL>@rtfb.lt "/home/rtfb/unpack.sh package$suffix"
ssh <EMAIL> "rm $full_path/db/pg/dbconf.yml"
ssh <EMAIL> "ln -s /home/rtfb/rtfblog-dbconf.yml $full_path/db/dbconf.yml"
ssh <EMAIL> "$full_path/migrate-db --db=$full_path/db --env=$goose_env"
ssh <EMAIL> "service rtfblog start"

echo "$env deployed."
{'fraction_non_alphanumeric': 0.17136465324384786, 'fraction_numerical': 0.0017897091722595079, 'mean_word_length': 4.3238095238095235, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2082559', 'n_tokens_mistral': 954, 'n_tokens_neox': 917, 'n_words': 196}