<commit_before>#!/bin/bash

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $dir

virtualenv -p python3 ~/venvs/register-publisher
source ~/venvs/register-publisher/bin/activate

pip install -r requirements.txt

#Set environment variable in supervisord according to deploying environment (default to development)
case "$DEPLOY_ENVIRONMENT" in
  development)
  SUPERVISOR_ENV="SETTINGS=\"config.DevelopmentConfig\""
  ;;
  preview)
  SUPERVISOR_ENV="SETTINGS=\"config.PreviewConfig\""
  ;;
  release)
  SUPERVISOR_ENV="SETTINGS=\"config.ReleaseConfig\""
  ;;
  preproduction)
  SUPERVISOR_ENV="SETTINGS=\"config.PreProductionConfig\""
  ;;
  production)
  SUPERVISOR_ENV="SETTINGS=\"config.ProductionConfig\""
  ;;
  *)
  SUPERVISOR_ENV="SETTINGS=\"config.DevelopmentConfig\""
  ;;
esac

if [ -n "$INCOMING_QUEUE_HOSTNAME" ]; then
  SUPERVISOR_ENV="$SUPERVISOR_ENV,INCOMING_QUEUE_HOSTNAME=\"$INCOMING_QUEUE_HOSTNAME\""
fi

if [ -n "$INCOMING_QUEUE" ]; then
  SUPERVISOR_ENV="$SUPERVISOR_ENV,INCOMING_QUEUE=\"$INCOMING_QUEUE\""
fi

if [ -n "$OUTGOING_QUEUE_HOSTNAME" ]; then
  SUPERVISOR_ENV="$SUPERVISOR_ENV,OUTGOING_QUEUE_HOSTNAME=\"$OUTGOING_QUEUE_HOSTNAME\""
fi

if [ -n "$OUTGOING_QUEUE" ]; then
  SUPERVISOR_ENV="$SUPERVISOR_ENV,OUTGOING_QUEUE=\"$OUTGOING_QUEUE\""
fi

echo "Adding register-publisherto supervisord..."
cat > /etc/supervisord.d/register-publisher.ini << EOF
[program:registerpublisher]
command=$HOME/venvs/register-publisher/bin/python run.py
directory=$dir
autostart=true
autorestart=true
user=$USER
environment=$SUPERVISOR_ENV
stopasgroup=true
EOF
<commit_msg>Split install into install and post-install .sh<commit_after>#!/bin/bash

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $dir

virtualenv -p python3 ~/venvs/register-publisher
source ~/venvs/register-publisher/bin/activate

pip install -r requirements.txt

{'fraction_non_alphanumeric': 0.14508328855454056, 'fraction_numerical': 0.0021493820526598604, 'mean_word_length': 6.0, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3972120', 'n_tokens_mistral': 716, 'n_tokens_neox': 680, 'n_words': 110}