<commit_before>#!/bin/bash
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'

export NODE_ENV=production

cd /srv/rachelandjoey.com
git reset --hard HEAD
git pull --rebase --prune
npm prune
npm i --production

if [[ -n $(docker ps -f 'name=rethinkdb' -q) ]]; then
  echo 'rethinkdb already running'
else
  sudo docker run --name rethinkdb -v "/srv/rethinkdb:/data" -d rethinkdb
fi

sudo docker build -t joeybaker/rachelandjoey /srv/rachelandjoey.com
sudo docker rm -f rachelandjoey
sudo docker run -d --restart=always --name rachelandjoey -e NODE_ENV=production \
  --link rethinkdb:rdb joeybaker/rachelandjoey

sudo docker rm -f bud
sudo docker run -d --restart=always -v "/srv/bud:/data" -p 443:443 --name bud \
  --link rachelandjoey:backend joeybaker/bud-tls

if [[ -n $(docker ps -f 'name=redirector' -q) ]]; then
  echo 'redirector already running'
else
  sudo docker run -d --restart=always -p 80:80 \
    --name redirector getable/https-redirect
fi

echo "ensuring assests are cached"
time curl -s https://rachelandjoey.com/static/index.js > /dev/null

# remove all unused images (saves space)
if [[ -n $(docker ps -a | grep 'Exited' | awk '{print $1}') ]]; then
  docker ps -a | grep 'Exited' | awk '{print $1}' | \
    xargs --no-run-if-empty docker rm  2> /dev/null
fi<commit_msg>deploy: attempt to fix strange exit #wip<commit_after>#!/bin/bash
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'

export NODE_ENV=production

cd /srv/rachelandjoey.com
git reset --hard HEAD
git pull --rebase --prune
npm prune
npm i --production

if [[ -n $(docker ps -f 'name=rethinkdb' -q) ]]; then
  echo 'rethinkdb already running'
else
  sudo docker run --name rethinkdb -v "/srv/rethinkdb:/data" -d rethinkdb
fi

sudo docker build -t joeybaker/rachelandjoey /srv/rachelandjoey.com
sudo docker rm -f rachelandjoey
sudo docker run -d --restart=always --name rachelandjoey -e NODE_ENV=production \
  --link rethinkdb:rdb joeybaker/rachelandjoey

sudo docker rm -f bud
sudo docker run -d --restart=always -v "/srv/bud:/data" -p 443:443 --name bud \
  --link rachelandjoey:backend joeybaker/bud-tls

if [[ -n $(docker ps -f 'name=redirector' -q) ]]; then
  echo 'redirector already running'
else
  sudo docker run -d --restart=always -p 80:80 \
    --name redirector getable/https-redirect
fi

echo "ensuring assests are cached"
time curl -s https://rachelandjoey.com/static/index.js > /dev/null

# remove all unused images (saves space)
if [[ -n $(docker ps -a | grep 'Exited' | awk '{print $1}') ]]; then
  docker ps -a | grep 'Exited' | awk '{print $1}' | xargs --no-run-if-empty docker rm
fi
{'fraction_non_alphanumeric': 0.137291280148423, 'fraction_numerical': 0.00927643784786642, 'mean_word_length': 3.478405315614618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '690540', 'n_tokens_mistral': 1061, 'n_tokens_neox': 981, 'n_words': 315}