Skip to content

Commit

Permalink
Add an application_name PostgreSQL connection parameter (#7275)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
This will let us more easily identify PostgreSQL sessions that come from
CVAT. See
<https://www.postgresql.org/docs/15/runtime-config-logging.html#GUC-APPLICATION-NAME>.

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->
```sql
SELECT * FROM pg_stat_activity;
```

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- ~~[ ] I have created a changelog fragment~~ <!-- see top comment in
CHANGELOG.md -->
- ~~[ ] I have updated the documentation accordingly~~
- ~~[ ] I have added tests to cover my changes~~
- ~~[ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))~~
- ~~[ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))~~

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
  • Loading branch information
SpecLad authored Feb 7, 2024
1 parent dc40be2 commit 22d4e04
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ class CVAT_QUEUES(Enum):
'USER': os.getenv('CVAT_POSTGRES_USER', 'root'),
'PASSWORD': postgres_password,
'PORT': os.getenv('CVAT_POSTGRES_PORT', 5432),
'OPTIONS': {
'application_name': os.getenv('CVAT_POSTGRES_APPLICATION_NAME', 'cvat'),
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion supervisord/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ process_name=%(program_name)s-%(process_num)d
socket=unix:///tmp/uvicorn.sock
command=python3 -m uvicorn --fd 0 --forwarded-allow-ips='*' cvat.asgi:application
autorestart=true
environment=CVAT_EVENTS_LOCAL_DB_FILENAME="events_%(process_num)03d.db"
environment=CVAT_EVENTS_LOCAL_DB_FILENAME="events_%(process_num)03d.db",CVAT_POSTGRES_APPLICATION_NAME="cvat:server"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d

Expand Down
4 changes: 2 additions & 2 deletions supervisord/utils.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ numprocs=1
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 notifications
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:notifications"
numprocs=1

[program:rqworker-cleaning]
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 cleaning
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:cleaning"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d
autorestart=true
2 changes: 1 addition & 1 deletion supervisord/worker.analytics_reports.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ childlogdir=%(ENV_HOME)s/logs/ ; where child log files will live
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 analytics_reports
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:analytics_reports"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d
autorestart=true
2 changes: 1 addition & 1 deletion supervisord/worker.annotation.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ childlogdir=%(ENV_HOME)s/logs/ ; where child log files will live
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 annotation
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:annotation"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d
autorestart=true
2 changes: 1 addition & 1 deletion supervisord/worker.export.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ childlogdir=%(ENV_HOME)s/logs/ ; where child log files will live
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 export
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:export"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d
autorestart=true
2 changes: 1 addition & 1 deletion supervisord/worker.import.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ childlogdir=%(ENV_HOME)s/logs/ ; where child log files will live
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 import
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:import"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d
autorestart=true
Expand Down
2 changes: 1 addition & 1 deletion supervisord/worker.quality_reports.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ childlogdir=%(ENV_HOME)s/logs/ ; where child log files will live
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 quality_reports
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:quality_reports"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d
autorestart=true
2 changes: 1 addition & 1 deletion supervisord/worker.webhooks.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ childlogdir=%(ENV_HOME)s/logs/ ; where child log files will live
command=%(ENV_HOME)s/wait_for_deps.sh
python3 %(ENV_HOME)s/manage.py rqworker -v 3 webhooks
--worker-class cvat.rqworker.DefaultWorker
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler"
environment=VECTOR_EVENT_HANDLER="SynchronousLogstashHandler",CVAT_POSTGRES_APPLICATION_NAME="cvat:worker:webhooks"
numprocs=%(ENV_NUMPROCS)s
process_name=%(program_name)s-%(process_num)d

Expand Down

0 comments on commit 22d4e04

Please sign in to comment.