Skip to content

Commit

Permalink
Merge pull request #3202 from owid/sql-query-logging
Browse files Browse the repository at this point in the history
🐝 Dev tooling: log all MySQL queries in dev
  • Loading branch information
larsyencken authored Feb 16, 2024
2 parents 74b204f + bc7319e commit 8aeb20b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ up: require create-if-missing.env ../owid-content tmp-downloads/owid_metadata.sq
yarn run tsc -b

@echo '==> Starting dev environment'
@mkdir -p logs
tmux new-session -s grapher \
-n docker 'docker-compose -f docker-compose.grapher.yml up' \; \
set remain-on-exit on \; \
Expand Down Expand Up @@ -83,6 +84,7 @@ up.devcontainer: create-if-missing.env.devcontainer tmp-downloads/owid_metadata.
yarn run tsc -b

@echo '==> Starting dev environment'
@mkdir -p logs
tmux new-session -s grapher \
-n admin \
'devTools/docker/wait-for-mysql.sh && yarn run tsc-watch -b --onSuccess "yarn startAdminServer"' \; \
Expand Down
16 changes: 16 additions & 0 deletions devTools/docker/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[mysqld]
# defaults
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
pid-file=/var/run/mysqld/mysqld.pid

# owid-specific
general_log = 1
general_log_file = /var/log/mysql/queries.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow-queries.log
long_query_time = 2
2 changes: 2 additions & 0 deletions docker-compose.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ services:
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./devTools/docker/my.cnf:/etc/my.cnf:ro
- mysql_data:/var/lib/mysql
- ./logs:/var/log/mysql
ports:
# Exposing via the port specified for Grapher
# Should always be the same as the WordPress port, because we store both DBs on the same server
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.grapher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ services:
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./devTools/my.cnf:/etc/my.cnf:ro
- mysql_data_public:/var/lib/mysql
- ./logs:/var/log/mysql
ports:
# Exposing via the port specified for Grapher
# Should always be the same as the WordPress port, because we store both DBs on the same server
Expand Down

0 comments on commit 8aeb20b

Please sign in to comment.