Skip to content

Commit

Permalink
Reorganise h's config files
Browse files Browse the repository at this point in the history
This commit reorganises h's `conf/` directory following a schema that I
plan to apply to our cookiecutter and the rest of our apps.

h's `conf/` directory presents some unique problems that don't apply to
our other apps because it has some extra configuration files that our
other apps don't have:

* Several `conf/*websocket*` config files for h's separate websocket
  app, which even needs an extra set of config files for when it's
  running in "monolithic" mode (used by `make run-docker` in development
  and in the Canada production environment).
* `websocket-newrelic.ini`: a New Relic configuration used by h's
  separate websocket app
* An `nginx.conf` file used by h's "internal" NGINX instance in
  production (there's no NGINX in h's development environment)
  • Loading branch information
seanh committed Dec 23, 2023
1 parent 4930737 commit c23f59f
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- '.github/workflows/deploy.yml'
- '.github/workflows/redeploy.yml'
- 'bin/logger'
- 'conf/development-app.ini'
- 'app.ini'
- 'conf/development.ini'
- 'production.ini'
- 'conf/supervisord*.conf'
- 'docs/*'
- 'requirements/*.in'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/data_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ jobs:
Env: ${{ inputs.Environment }}
Timeout: 7200
Region: ${{ inputs.Region }}
Command: 'newrelic-admin run-program python bin/run_data_task.py --config-file conf/app.ini --task ${{ inputs.Task }}'
Command: 'newrelic-admin run-program python bin/run_data_task.py --config-file conf/production.ini --task ${{ inputs.Task }}'
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- '.github/*'
- 'bin/create-testdb'
- 'bin/install-python'
- 'conf/development-app.ini'
- 'conf/development.ini'
- 'conf/supervisord-dev.conf'
- 'conf/websocket-dev.ini'
- 'docs/*'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report_refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
Env: 'prod'
Timeout: 3600
Region: 'all'
Command: 'newrelic-admin run-program python bin/run_data_task.py --config-file conf/app.ini --task report/refresh'
Command: 'newrelic-admin run-program python bin/run_data_task.py --config-file conf/production.ini --task report/refresh'
secrets: inherit
9 changes: 0 additions & 9 deletions conf/development-app.ini → conf/development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ secret_key: notverysecretafterall

sqlalchemy.url: postgresql://postgres@localhost/postgres

[server:main]
use: egg:gunicorn#main
host: 0.0.0.0
port: 5000
proc_name: web
graceful_timeout: 0
timeout: 0
errorlog: -

[loggers]
keys = root, gunicorn.error, h

Expand Down
3 changes: 3 additions & 0 deletions conf/gunicorn-dev.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bind = "0.0.0.0:5000"
graceful_timeout = 0
timeout = 0
5 changes: 5 additions & 0 deletions conf/gunicorn-websocket-dev.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bind = "localhost:5001"
worker_class = "h.streamer.Worker"
graceful_timeout = 0
workers = 2
worker_connections = 8
5 changes: 5 additions & 0 deletions conf/gunicorn-websocket-monolithic.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bind = "unix:/tmp/gunicorn-websocket.sock"
worker_class = "h.streamer.Worker"
graceful_timeout = 0
workers = 2
worker_connections = 8192
5 changes: 5 additions & 0 deletions conf/gunicorn-websocket.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bind = "0.0.0.0:5000"
worker_class = "h.streamer.Worker"
graceful_timeout = 0
workers = 2
worker_connections = 8192
1 change: 1 addition & 0 deletions conf/gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bind = "unix:/tmp/gunicorn-web.sock"
5 changes: 0 additions & 5 deletions conf/app.ini → conf/production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ use: call:h.app:create_app
[filter:proxy-prefix]
use: egg:PasteDeploy#prefix

[server:main]
use: egg:gunicorn#main
bind: unix:/tmp/gunicorn-web.sock
proc_name: web

[loggers]
keys = root, alembic, gunicorn.error, h

Expand Down
4 changes: 2 additions & 2 deletions conf/supervisord-dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ nodaemon = true
silent = true

[program:web]
command = pserve --reload conf/development-app.ini
command = gunicorn --paste conf/development.ini --config conf/gunicorn-dev.conf.py
stdout_events_enabled=true
stderr_events_enabled=true
stopsignal = KILL
stopasgroup = true
autostart = %(ENV_ENABLE_WEB)s

[program:websocket]
command = pserve --reload conf/websocket-dev.ini
command = gunicorn --paste conf/websocket-dev.ini --config conf/gunicorn-websocket-dev.conf.py
stdout_events_enabled=true
stderr_events_enabled=true
stopsignal = KILL
Expand Down
13 changes: 11 additions & 2 deletions conf/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,30 @@ stderr_events_enabled=true
autostart = %(ENV_ENABLE_NGINX)s

[program:web]
command=newrelic-admin run-program pserve conf/app.ini
command=newrelic-admin run-program gunicorn --paste conf/production.ini --config conf/gunicorn.conf.py
stdout_logfile=NONE
stderr_logfile=NONE
stdout_events_enabled=true
stderr_events_enabled=true
autostart = %(ENV_ENABLE_WEB)s

[program:websocket]
command=pserve %(ENV_WEBSOCKET_CONFIG)s
command=newrelic-admin run-program gunicorn --paste conf/websocket.ini --config conf/gunicorn-websocket.conf.py
stdout_logfile=NONE
stderr_logfile=NONE
stdout_events_enabled=true
stderr_events_enabled=true
autostart = %(ENV_ENABLE_WEBSOCKET)s

[program:websocket-monolithic]
command=newrelic-admin run-program gunicorn --paste conf/websocket-monolithic.ini --config conf/gunicorn-websocket-monolithic.conf.py
stdout_logfile=NONE
stderr_logfile=NONE
stdout_events_enabled=true
stderr_events_enabled=true
autostart = %(ENV_ENABLE_WEBSOCKET_MONOLITHIC)s
process_name = websocket

[program:worker]
command=newrelic-admin run-program hypothesis celery worker --loglevel=INFO
stdout_logfile=NONE
Expand Down
11 changes: 0 additions & 11 deletions conf/websocket-dev.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ secret_key: notverysecretafterall
# SQLAlchemy configuration -- See SQLAlchemy documentation
sqlalchemy.url: postgresql://postgres@localhost/postgres

[server:main]
use: egg:gunicorn#main
host: localhost
port: 5001
worker_class: h.streamer.Worker
graceful_timeout: 0
proc_name: websocket
# This is very low so you can see what happens when we run out
workers: 2
worker_connections: 8

[loggers]
keys = root, gunicorn.error, h

Expand Down
9 changes: 0 additions & 9 deletions conf/websocket-monolithic.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
[app:main]
use: call:h.streamer:create_app

[server:main]
use: egg:gunicorn#main
bind: unix:/tmp/gunicorn-websocket.sock
worker_class: h.streamer.Worker
graceful_timeout: 0
proc_name: websocket
workers: 2
worker_connections: 8192

[loggers]
keys = root, gunicorn.error, h.streamer

Expand Down
10 changes: 0 additions & 10 deletions conf/websocket-separate.ini → conf/websocket.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
[app:main]
use: call:h.streamer:create_app

[server:main]
use: egg:gunicorn#main
host: 0.0.0.0
port: 5000
worker_class: h.streamer.Worker
graceful_timeout: 0
proc_name: websocket
workers: 2
worker_connections: 8192

[loggers]
keys = root, gunicorn.error, h.streamer

Expand Down
2 changes: 1 addition & 1 deletion h/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def bootstrap(app_url, dev=False):
else:
raise click.ClickException("the app URL must be set in production mode!")

config = "conf/development-app.ini" if dev else "conf/app.ini"
config = "conf/development.ini" if dev else "conf/production.ini"

paster.setup_logging(config)
request = Request.blank("/", base_url=app_url)
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/bin/run_data_task_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_reporting_tasks(self, environ):
sys.executable,
"bin/run_data_task.py",
"--config-file",
"conf/development-app.ini",
"conf/development.ini",
"--task",
task_name,
],
Expand Down

0 comments on commit c23f59f

Please sign in to comment.