From: Ammar Faizi <[email protected]>
To: GNU/Weeb Mailing List <[email protected]>
Cc: Ammar Faizi <[email protected]>,
Muhammad Rizki <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH v1 2/2] Allow custom MySQL port from the env file
Date: Sun, 25 Dec 2022 05:00:08 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
From: Ammar Faizi <[email protected]>
I don't always use 3306 as the MySQL server port. Allow custom port
to be configured from the env file!
Signed-off-by: Ammar Faizi <[email protected]>
---
daemon/dc.py | 7 +++++++
daemon/discord.env.example | 1 +
daemon/telegram.env.example | 1 +
daemon/tg.py | 7 +++++++
4 files changed, 16 insertions(+)
diff --git a/daemon/dc.py b/daemon/dc.py
index f9b57e5..a9d5ebd 100644
--- a/daemon/dc.py
+++ b/daemon/dc.py
@@ -29,10 +29,17 @@ def main():
logger = BotLogger(Platform.DISCORD)
logger.init()
+ port = os.getenv("DB_PORT")
+ if not port:
+ port = 3306
+ else:
+ port = int(port)
+
client = GWClient(
db_conn=connector.connect(
host=os.getenv("DB_HOST"),
user=os.getenv("DB_USER"),
+ port=port,
password=os.getenv("DB_PASS"),
database=os.getenv("DB_NAME")
),
diff --git a/daemon/discord.env.example b/daemon/discord.env.example
index 60fcfac..de7e9f4 100644
--- a/daemon/discord.env.example
+++ b/daemon/discord.env.example
@@ -4,6 +4,7 @@ DISCORD_TOKEN=
# Input your MySQL connection below
DB_HOST=
DB_USER=
+DB_PORT=3306
DB_PASS=
DB_NAME=
diff --git a/daemon/telegram.env.example b/daemon/telegram.env.example
index a070dd0..a42d86c 100644
--- a/daemon/telegram.env.example
+++ b/daemon/telegram.env.example
@@ -9,6 +9,7 @@ BOT_TOKEN=
# MySQL Config
DB_HOST=
DB_USER=
+DB_PORT=3306
DB_PASS=
DB_NAME=
diff --git a/daemon/tg.py b/daemon/tg.py
index 8382c29..73ff2b9 100644
--- a/daemon/tg.py
+++ b/daemon/tg.py
@@ -21,6 +21,12 @@ def main():
logger = BotLogger()
logger.init()
+ port = os.getenv("DB_PORT")
+ if not port:
+ port = 3306
+ else:
+ port = int(port)
+
client = DaemonClient(
"telegram/storage/EmailScraper",
api_id=int(os.getenv("API_ID")),
@@ -30,6 +36,7 @@ def main():
conn=connector.connect(
host=os.getenv("DB_HOST"),
user=os.getenv("DB_USER"),
+ port=port,
password=os.getenv("DB_PASS"),
database=os.getenv("DB_NAME")
),
--
Ammar Faizi
next prev parent reply other threads:[~2022-12-24 22:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-24 22:00 [PATCH v1 0/2] A bug fix and allow custom MySQL port Ammar Faizi
2022-12-24 22:00 ` [PATCH v1 1/2] telegram: listener: Fix missing MySQL error recovery function Ammar Faizi
2022-12-24 22:59 ` Muhammad Rizki
2022-12-24 22:00 ` Ammar Faizi [this message]
2022-12-24 22:57 ` [PATCH v1 2/2] Allow custom MySQL port from the env file Muhammad Rizki
2022-12-24 22:59 ` Ammar Faizi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox