Skip to content

Commit 870bc0f

Browse files
committed
⚙️ LUA_SCRIPT & LOG_FILE env
1 parent 16f401f commit 870bc0f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exec /opt/mysql-proxy/bin/mysql-proxy \\\\\n\
2323
--plugins=proxy \\\\\n\
2424
--proxy-address=\${PROXY_DB_HOST}:\${PROXY_DB_PORT} \\\\\n\
2525
--proxy-backend-addresses=\${REMOTE_DB_HOST}:\${REMOTE_DB_PORT} \\\\\n\
26-
--proxy-lua-script=\${PROXY_LUA_SCRIPT}\n\
26+
--proxy-lua-script=\${LUA_SCRIPT}\n\
2727
" >> /opt/entrypoint.sh && \
2828
chmod u+x /opt/entrypoint.sh
2929
EXPOSE 4040 4041

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ services:
5353
PROXY_DB_PORT: 3306
5454
REMOTE_DB_HOST: mysql
5555
REMOTE_DB_PORT: 3306
56-
PROXY_LUA_SCRIPT: "/opt/mysql-proxy/conf/main.lua"
56+
LUA_SCRIPT: "/opt/mysql-proxy/conf/main.lua"
5757
depends_on:
5858
- mysql
5959
```
@@ -79,13 +79,14 @@ end
7979
PROXY_DB_PORT: 3306
8080
REMOTE_DB_HOST: mysql
8181
REMOTE_DB_PORT: 3306
82-
PROXY_LUA_SCRIPT: "/opt/mysql-proxy/conf/log.lua"
82+
LUA_SCRIPT: "/opt/mysql-proxy/conf/log.lua"
83+
LOG_FILE: "/opt/mysql-proxy/logs/mysql.log"
8384
...
8485
```
8586

8687
`/mysql-proxy/log.lua` https://gist.github.com/simonw/1039751
8788
```
88-
local log_file = '/opt/mysql-proxy/logs/mysql.log'
89+
local log_file = os.getenv("LOG_FILE")
8990
9091
local fh = io.open(log_file, "a+")
9192

log.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
-- This script will log the current date and time, the connection id
2828
-- and the query to a file named "mysql.log"
2929
--
30-
local log_file = '/opt/mysql-proxy/logs/mysql.log'
30+
local log_file = os.getenv("LOG_FILE")
3131

3232
local fh = io.open(log_file, "a+")
3333

0 commit comments

Comments
 (0)