<commit_before>#!/bin/bash -e

job_dir=/var/vcap/jobs/mysql
run_dir=/var/vcap/sys/run/galera-healthcheck
log_dir=/var/vcap/sys/log/galera-healthcheck
package_dir=/var/vcap/packages/galera-healthcheck
pidfile=$run_dir/galera-healthcheck.pid

source /var/vcap/packages/cf-mysql-common/pid_utils.sh

case $1 in

  start)
    log "Starting galera-healthcheck..."
    pid_guard $pidfile "Galera Healthcheck"

    mkdir -p $run_dir
    chown -R vcap:vcap $run_dir

    mkdir -p $log_dir
    chown -R vcap:vcap $log_dir

    cd $package_dir

    ulimit -n <%= p('cf_mysql.mysql.max_open_files') %> # HIGH Ulimit for SST of lots of tables (in case we run the bootstrap errand)

    su - vcap -c -o pipefail \
      "$package_dir/bin/galera-healthcheck \
        -configPath=$job_dir/config/galera_healthcheck_config.yaml \
        >>$log_dir/galera-healthcheck.stdout.log \
        2>>$log_dir/galera-healthcheck.stderr.log &"

    log "Starting galera-healthcheck... done"
    ;;

  stop)
    log "Stopping galera-healthcheck..."
    kill_and_wait $pidfile
    log "Stopping galera-healthcheck... done"
    ;;

  *)
    echo "Usage: galera-healthcheck_ctl {start|stop}"
    ;;

esac<commit_msg>Use `chpst` instead of `su` to start galera-healthcheck<commit_after>#!/usr/bin/env bash

set -eo pipefail

job_dir=/var/vcap/jobs/mysql
run_dir=/var/vcap/sys/run/galera-healthcheck
log_dir=/var/vcap/sys/log/galera-healthcheck
package_dir=/var/vcap/packages/galera-healthcheck
pidfile=$run_dir/galera-healthcheck.pid

source /var/vcap/packages/cf-mysql-common/pid_utils.sh

case $1 in

  start)
    log "Starting galera-healthcheck..."
    pid_guard $pidfile "Galera Healthcheck"

    mkdir -p $run_dir
    chown -R vcap:vcap $run_dir

    mkdir -p $log_dir
    chown -R vcap:vcap $log_dir

    cd $package_dir

    ulimit -n <%= p('cf_mysql.mysql.max_open_files') %> # HIGH Ulimit for SST of lots of tables (in case we run the bootstrap errand)

    chpst -u vcap:vcap bash -c "
      $package_dir/bin/galera-healthcheck \
        -configPath=$job_dir/config/galera_healthcheck_config.yaml \
        >>$log_dir/galera-healthcheck.stdout.log \
        2>>$log_dir/galera-healthcheck.stderr.log" &

    log "Starting galera-healthcheck... done"
    ;;

  stop)
    log "Stopping galera-healthcheck..."
    kill_and_wait $pidfile
    log "Stopping galera-healthcheck... done"
    ;;

  *)
    echo "Usage: galera-healthcheck_ctl {start|stop}"
    ;;

esac
{'fraction_non_alphanumeric': 0.1266393442622951, 'fraction_numerical': 0.001639344262295082, 'mean_word_length': 3.1025210084033614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2266255', 'n_tokens_mistral': 947, 'n_tokens_neox': 890, 'n_words': 173}