1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-23 01:39:27 +02:00

update mysql-proxy

This commit is contained in:
kev 2016-05-09 23:28:47 +08:00
parent 0cd923ef0b
commit f7859319ec
6 changed files with 45 additions and 3 deletions

View File

@ -66,6 +66,7 @@ A collection of delicious docker recipes.
- [x] moodle :beetle: - [x] moodle :beetle:
- [x] mosquitto - [x] mosquitto
- [x] motion-arm :+1: - [x] motion-arm :+1:
- [x] mysql-proxy
- [x] nginad - [x] nginad
- [x] nginx - [x] nginx
- [x] ngrok :+1: - [x] ngrok :+1:

View File

@ -10,7 +10,7 @@ RUN set -xe \
&& apt-get install -y mysql-proxy \ && apt-get install -y mysql-proxy \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
EXPOSE 4040 EXPOSE 4040 4041
ENTRYPOINT ["mysql-proxy"] ENTRYPOINT ["mysql-proxy"]
CMD ["--help"] CMD ["--help-all"]

View File

@ -5,4 +5,16 @@ mysql-proxy
MySQL client/server protocol and provides communication between one or more MySQL client/server protocol and provides communication between one or more
MySQL servers and one or more MySQL clients. MySQL servers and one or more MySQL clients.
```
# run docker container
$ docker-compose up -d
# view log in shell
$ journalctl -f CONTAINER_NAME=mysql-proxy
# view log in python
$ apt install python3-systemd
$ python3 code.py
```
[1]: https://github.com/mysql/mysql-proxy [1]: https://github.com/mysql/mysql-proxy

View File

@ -1,3 +1,5 @@
io.stdout:setvbuf 'no'
function read_query(packet) function read_query(packet)
if packet:byte() == proxy.COM_QUERY then if packet:byte() == proxy.COM_QUERY then
print("we got a normal query: " .. packet:sub(2)) print("we got a normal query: " .. packet:sub(2))

20
mysql-proxy/code.py Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env python3
import select from systemd
import journal
j = journal.Reader()
j.log_level(journal.LOG_INFO)
j.add_match(CONTAINER_NAME="mysql-proxy")
j.seek_tail()
j.get_previous()
p = select.poll()
p.register(j, j.get_events())
while p.poll():
if j.process() != journal.APPEND:
continue
for entry in j:
if entry['MESSAGE']:
print(str(entry['__REALTIME_TIMESTAMP']), entry['MESSAGE'])

View File

@ -1,11 +1,18 @@
mysql-proxy: mysql-proxy:
image: vimagick/mysql-proxy image: vimagick/mysql-proxy
container_name: mysql-proxy
command: > command: >
--proxy-address=:4040 --proxy-address=:4040
--proxy-backend-addresses=mysql-server:3306 --proxy-backend-addresses=mysql-server:3306
--proxy-lua-script=/code.lua --proxy-lua-script=/code.lua
--admin-address=:4041
--admin-username=root
--admin-password=root
--admin-lua-script=/usr/lib/mysql-proxy/lua/admin.lua
ports: ports:
- "3306:4040" - "4040:4040"
- "4041:4041"
volumes: volumes:
- ./code.lua:/code.lua - ./code.lua:/code.lua
log_driver: journald
restart: always restart: always