PheeZz / wireguard-bot

telegram bot for manage Wireguard server
MIT License
81 stars 20 forks source link

troubles after server reboot #17

Closed pj777777777777777777777 closed 1 month ago

pj777777777777777777777 commented 1 month ago

× wireguard-bot.service - WireGuard VPN Bot Loaded: loaded (/etc/systemd/system/wireguard-bot.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2024-08-07 23:38:11 MSK; 22s ago Process: 1237 ExecStart=/bin/bash -c cd ~/wireguard-bot/ && /root/.cache/pypoetry/virtualenvs/wireguard-bot-HQhWNfUr-py3.10/bin/python3.10 app.py (code=exited, status=1/FAILURE) Main PID: 1237 (code=exited, status=1/FAILURE) CPU: 399ms

Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: for mapping in mappings: Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: File "/root/.cache/pypoetry/virtualenvs/wireguard-bot-HQhWNfUr-py3.10/lib/python3.10/site-packages/dotenv/parser.py", line 180, in parse_stream Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: reader = Reader(stream) Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: File "/root/.cache/pypoetry/virtualenvs/wireguard-bot-HQhWNfUr-py3.10/lib/python3.10/site-packages/dotenv/parser.py", line 71, in init Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: self.string = stream.read() Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: File "/usr/lib/python3.10/codecs.py", line 322, in decode Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: (result, consumed) = self._buffer_decode(data, self.errors, final) Aug 07 23:38:11 v98044.hosted-by-vdsina.com bash[1237]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 350: invalid continuation byte Aug 07 23:38:11 v98044.hosted-by-vdsina.com systemd[1]: wireguard-bot.service: Main process exited, code=exited, status=1/FAILURE Aug 07 23:38:11 v98044.hosted-by-vdsina.com systemd[1]: wireguard-bot.service: Failed with result 'exit-code'.

PheeZz commented 1 month ago
bash[1237]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 350: invalid continuation byte

Looks like broken or encoded with specific codec (not utf-8) .env file by some reason.

Get file encoding: file -bi wireguard-bot/data/.env About converting to utf-8: https://www.baeldung.com/linux/unicode-utf-8-conversion

Check the wireguard-bot/data/.env with cat/nano/vi/vim util, it must be something like:

#telegram bot token
WG_BOT_TOKEN = <str>
#ip of your wireguard server
WG_SERVER_IP = <str>
#port of your wireguard server
WG_SERVER_PORT = '51830'
#server's public key
WG_SERVER_PUBLIC_KEY = <str>
#server's preshared key
WG_SERVER_PRESHARED_KEY= <str>
#path to wireguard config file, default /etc/wireguard/wg0.conf
WG_CFG_PATH = '/etc/wireguard/wg0.conf'
#token for telegram invoice payments, if you don't use payments, just leave it empty (NOW IT'S NOT WORKING)
PAYMENTS_TOKEN = <str>
#your telegram id, you can get it from @userinfobot or @myidbot or @RawDataBot
ADMINS_IDS = <str>
#your bank card number, if you will use payments with "handmade" method
PAYMENT_CARD = <str>
#any text you want to show in the start of every peer config file (for example in case MYVPN_pheezz_PC.conf - "MYVPN" is prefix)
CONFIGS_PREFIX = <str>
#how much subscription costs in rubles
BASE_SUBSCRIPTION_MONTHLY_PRICE_RUBLES = <int>
#dns server for your peers, default 1.1.1.1 if you don't use AdGuard Home, else 10.0.0.1
PEER_DNS = '1.1.1.1'

#name of your database
DATABASE = <str>
#database user
DB_USER = <str>
#database user's password
DB_USER_PASSWORD = <str>
#database host, default localhost
DB_HOST = 'localhost'
#database port, default 5432
DB_PORT = '5432'