<commit_before>"""
"""
import errno
import os
import shutil
import subprocess
import time
from os.path import exists, join

from gravity.io import debug, error, info, warn
from gravity.process_manager import BaseProcessManager
from gravity.state import GracefulMethod
from gravity.util import which

from supervisor import supervisorctl


SUPERVISORD_CONF_TEMPLATE = """;
; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN
;

[unix_http_server]
file = {supervisor_state_dir}/supervisor.sock

[supervisord]
logfile = {supervisor_state_dir}/supervisord.log
pidfile = {supervisor_state_dir}/supervisord.pid
loglevel = info
nodaemon = false

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl = unix://{supervisor_state_dir}/supervisor.sock

[include]
files = {supervisord_conf_dir}/*.d/*.conf {supervisord_conf_dir}/*.conf
"""

# TODO: with more templating you only need one of these
SUPERVISORD_SERVICE_TEMPLATES = {}
SUPERVISORD_SERVICE_TEMPLATES["unicornherder"] = """;
; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN
;

[program:{program_name}]
command         = {command}
directory       = {galaxy_root}
umask           = {galaxy_umask}
autostart       = true
autorestart     = true
startsecs       = 15
stopwaitsecs    = 65
environment     = GALAXY_CONFIG_FILE="{galaxy_conf}"
numprocs        = 1
stdout_logfile  = {log_file}
redirect_stderr = true
{process_name_opt}
"""  # noqa: E501

SUPERVISORD_SERVICE_TEMPLATES["gunicorn"] = """;
; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN
;

[program:{program_name}]
command         = {command}
directory       = {galaxy_root}<commit_msg>Use relative paths in supervisord, which can't handle quoting or spaces in paths, but can handle paths relative to the config file.<commit_after>"""
"""
import errno
import os
import shutil
import subprocess
import time
from os.path import exists, join

from gravity.io import debug, error, info, warn
from gravity.process_manager import BaseProcessManager
from gravity.state import GracefulMethod
from gravity.util import which

from supervisor import supervisorctl


SUPERVISORD_CONF_TEMPLATE = """;
; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN
;

[unix_http_server]
file = %(here)s/supervisor.sock

[supervisord]
logfile = %(here)s/supervisord.log
pidfile = %(here)s/supervisord.pid
loglevel = info
nodaemon = false

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl = unix://%(here)s/supervisor.sock

[include]
files = supervisord.conf.d/*.d/*.conf supervisord.conf.d/*.conf
"""

# TODO: with more templating you only need one of these
SUPERVISORD_SERVICE_TEMPLATES = {}
SUPERVISORD_SERVICE_TEMPLATES["unicornherder"] = """;
; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN
;

[program:{program_name}]
command         = {command}
directory       = {galaxy_root}
umask           = {galaxy_umask}
autostart       = true
autorestart     = true
startsecs       = 15
stopwaitsecs    = 65
environment     = GALAXY_CONFIG_FILE="{galaxy_conf}"
numprocs        = 1
stdout_logfile  = {log_file}
redirect_stderr = true
{process_name_opt}
"""  # noqa: E501

SUPERVISORD_SERVICE_TEMPLATES["gunicorn"] = """;
; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN
;

[program:{program_name}]
command         = {command}
directory       = {galaxy_root}
{'fraction_non_alphanumeric': 0.0933028048082427, 'fraction_numerical': 0.0045792787635947334, 'mean_word_length': 4.815307820299501, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5821935', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1118, 'n_words': 292}