2018-11-15 04:09:57 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
from g import config_dir, DEFAULT_GID, DEFAULT_UID, templates_dir
|
2019-08-01 10:02:08 +02:00
|
|
|
from utils.misc import prepare_dir
|
2018-11-15 04:09:57 +01:00
|
|
|
from utils.jinja import render_jinja
|
|
|
|
|
|
|
|
job_config_dir = os.path.join(config_dir, "jobservice")
|
|
|
|
job_service_env_template_path = os.path.join(templates_dir, "jobservice", "env.jinja")
|
|
|
|
job_service_conf_env = os.path.join(config_dir, "jobservice", "env")
|
|
|
|
job_service_conf_template_path = os.path.join(templates_dir, "jobservice", "config.yml.jinja")
|
|
|
|
jobservice_conf = os.path.join(config_dir, "jobservice", "config.yml")
|
|
|
|
|
|
|
|
def prepare_job_service(config_dict):
|
2019-08-01 10:02:08 +02:00
|
|
|
prepare_dir(job_config_dir, uid=DEFAULT_UID, gid=DEFAULT_GID)
|
2018-11-15 04:09:57 +01:00
|
|
|
|
2019-05-15 04:28:52 +02:00
|
|
|
log_level = config_dict['log_level'].upper()
|
|
|
|
|
2018-11-15 04:09:57 +01:00
|
|
|
# Job log is stored in data dir
|
|
|
|
job_log_dir = os.path.join('/data', "job_logs")
|
2019-08-01 10:02:08 +02:00
|
|
|
prepare_dir(job_log_dir, uid=DEFAULT_UID, gid=DEFAULT_GID)
|
2018-11-15 04:09:57 +01:00
|
|
|
# Render Jobservice env
|
|
|
|
render_jinja(
|
|
|
|
job_service_env_template_path,
|
|
|
|
job_service_conf_env,
|
|
|
|
**config_dict)
|
|
|
|
|
|
|
|
# Render Jobservice config
|
|
|
|
render_jinja(
|
|
|
|
job_service_conf_template_path,
|
|
|
|
jobservice_conf,
|
|
|
|
uid=DEFAULT_UID,
|
|
|
|
gid=DEFAULT_GID,
|
2020-02-11 06:47:55 +01:00
|
|
|
internal_tls=config_dict['internal_tls'],
|
2018-11-15 04:09:57 +01:00
|
|
|
max_job_workers=config_dict['max_job_workers'],
|
2019-05-15 04:28:52 +02:00
|
|
|
redis_url=config_dict['redis_url_js'],
|
2021-03-15 17:25:53 +01:00
|
|
|
level=log_level,
|
|
|
|
metric=config_dict['metric'])
|