Skip to content

Commit

Permalink
render configs
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Nov 1, 2023
1 parent 21341bd commit cd2a81b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions configs/asset-dashboard.conf.supervisor
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[program:{{ app_name }}-{{ deployment_id }}]
user=datamade
process_name={{ app_name }}
stdout_logfile=/var/log/{{ app_name }}-{{ deployment_id }}-out.log
stdout_logfile_maxbytes=10MB
stderr_logfile=/var/log/{{ app_name }}-{{ deployment_id }}-err.log
stderr_logfile_maxbytes=10MB
directory=/home/datamade/{{ app_name }}-{{ deployment_id }}
command=/home/datamade/.virtualenvs/{{ app_name }}-{{ deployment_id }}/bin/gunicorn -t 180 --log-level debug -b unix:/tmp/{{ app_name }}-{{ deployment_id }}.sock docsearch.wsgi:application
42 changes: 42 additions & 0 deletions scripts/render_configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
if __name__ == "__main__":

import sys

from os.path import abspath, dirname, join

path = abspath(join(dirname(__file__), '..'))
sys.path.insert(1, path)

from jinja2 import Template

deployment_id, deployment_group, domain, app_name = sys.argv[1:]

nginx_template_path = '/home/datamade/{0}-{1}/configs/{0}-{2}.conf.nginx'.format(
app_name, deployment_id, deployment_group)
nginx_outpath = '/etc/nginx/conf.d/{}.conf'.format(app_name)
supervisor_template_path = '/home/datamade/{0}-{1}/configs/{0}-{2}.conf.supervisor'.format(
app_name, deployment_id, deployment_group)
supervisor_outpath = '/etc/supervisor/conf.d/{}.conf'.format(app_name)

with open(nginx_template_path) as f:
nginx_conf = Template(f.read())
context = {
'deployment_id': deployment_id,
'domain': domain,
'app_name': app_name,
}
nginx_rendered = nginx_conf.render(context)

with open(supervisor_template_path) as f:
supervisor_conf = Template(f.read())
context = {
'deployment_id': deployment_id,
'app_name': app_name,
}
supervisor_rendered = supervisor_conf.render(context)

with open(nginx_outpath, 'w') as out:
out.write(nginx_rendered)

with open(supervisor_outpath, 'w') as out:
out.write(supervisor_rendered)

0 comments on commit cd2a81b

Please sign in to comment.