Skip to content

Commit

Permalink
Adjustments for app-sre deployment (ibutsu#256)
Browse files Browse the repository at this point in the history
* Rework templates for app-sre deployment

* Updating templates

* Use f-strings

* Change name of 'flower' image

* Combine all backend components into 1 backend template

* Move celery broker config out of pgsql 'if' statement
  • Loading branch information
bsquizz authored and jjaquish committed Aug 9, 2022
1 parent db4b4ac commit 7752783
Show file tree
Hide file tree
Showing 7 changed files with 518 additions and 307 deletions.
28 changes: 27 additions & 1 deletion backend/ibutsu_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ def _make_sql_url(hostname, database, **kwargs):
return "postgresql://{}/{}".format(url, database)


def _make_broker_url(env_var_value, hostname, password, port):
if env_var_value:
return env_var_value
user_pass_str = f":{password}@" if password else ""
return f"redis://{user_pass_str}{hostname}:{port}"


def get_app(**extra_config):
"""Create the WSGI application"""

Expand Down Expand Up @@ -64,9 +71,28 @@ def get_app(**extra_config):
port=config.get("POSTGRESQL_PORT"),
user=config.get("POSTGRESQL_USER"),
password=config.get("POSTGRESQL_PASSWORD"),
)
),
}
)

# Set celery broker URL
config.update(
{
"CELERY_BROKER_URL": _make_broker_url(
config.get("CELERY_BROKER_URL"),
config.get("REDIS_HOSTNAME"),
config.get("REDIS_PASSWORD"),
config.get("REDIS_PORT"),
),
"CELERY_RESULT_BACKEND": _make_broker_url(
config.get("CELERY_RESULT_BACKEND"),
config.get("REDIS_HOSTNAME"),
config.get("REDIS_PASSWORD"),
config.get("REDIS_PORT"),
),
}
)

# Load any extra config
config.update(extra_config)

Expand Down
Loading

0 comments on commit 7752783

Please sign in to comment.