WLAN-Pi / pi-gen

Image build tool for WLAN Pi RPi and CM4 based hardware
BSD 3-Clause "New" or "Revised" License
48 stars 7 forks source link

Chat bot service failing #46

Closed willcurtis closed 11 months ago

willcurtis commented 11 months ago

Not a critical one but thought I would raise it. the Chat bot sets up ok and runs when starting/restarting the service:

`wlanpi@wlanpi-903:~$ sudo systemctl status wlanpi-chat-bot ● wlanpi-chat-bot.service - Telegram chatbot for the WLAN Pi Loaded: loaded (/lib/systemd/system/wlanpi-chat-bot.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2023-10-05 05:43:17 CDT; 21s ago Main PID: 98549 (chatbot) Tasks: 2 (limit: 3932) CPU: 1.465s CGroup: /system.slice/wlanpi-chat-bot.service ├─98549 /opt/wlanpi-chat-bot/bin/python /usr/sbin/chatbot └─98639 /opt/wlanpi-chat-bot/bin/python /usr/sbin/chatbot

Oct 05 05:43:17 wlanpi-903 systemd[1]: Started Telegram chatbot for the WLAN Pi. Oct 05 05:43:18 wlanpi-903 chatbot[98549]: 2023-10-05 05:43:18,389 [INFO] TelegramAlert: We were offline, but we're back online.`

It sends the status message as expected but if you reply with a command the service exits immediately:

`wlanpi@wlanpi-903:~$ sudo systemctl status wlanpi-chat-bot ● wlanpi-chat-bot.service - Telegram chatbot for the WLAN Pi Loaded: loaded (/lib/systemd/system/wlanpi-chat-bot.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2023-10-05 05:43:48 CDT; 2s ago Process: 98549 ExecStart=/usr/sbin/chatbot (code=exited, status=1/FAILURE) Main PID: 98549 (code=exited, status=1/FAILURE) CPU: 1.669s

Oct 05 05:43:48 wlanpi-903 chatbot[98549]: File "/usr/sbin/chatbot", line 5, in Oct 05 05:43:48 wlanpi-903 chatbot[98549]: from chatbot.main import main Oct 05 05:43:48 wlanpi-903 chatbot[98549]: File "/opt/wlanpi-chat-bot/lib/python3.9/site-packages/chatbot/main.py", line 5, in Oct 05 05:43:48 wlanpi-903 chatbot[98549]: sys.exit(chatbot.main()) Oct 05 05:43:48 wlanpi-903 chatbot[98549]: File "/opt/wlanpi-chat-bot/lib/python3.9/site-packages/chatbot/chatbot.py", line 326, in main Oct 05 05:43:48 wlanpi-903 chatbot[98549]: if (chat_id == chat_id_check) and (username == username_check): Oct 05 05:43:48 wlanpi-903 chatbot[98549]: UnboundLocalError: local variable 'username_check' referenced before assignment Oct 05 05:43:48 wlanpi-903 systemd[1]: wlanpi-chat-bot.service: Main process exited, code=exited, status=1/FAILURE Oct 05 05:43:48 wlanpi-903 systemd[1]: wlanpi-chat-bot.service: Failed with result 'exit-code'. Oct 05 05:43:48 wlanpi-903 systemd[1]: wlanpi-chat-bot.service: Consumed 1.669s CPU time.`

willcurtis commented 11 months ago

Posted in the wrong place.