RITlug / teleirc

Go implementation of a Telegram <=> IRC bridge for use with any IRC channel and Telegram group
https://docs.teleirc.com/
GNU General Public License v3.0
141 stars 45 forks source link

teleirc exits with code 0/success even on failure #359

Closed fgaz closed 2 years ago

fgaz commented 3 years ago

Summary

teleirc exits with code 0/success even on failure. This is a problem for service supervisors that try to restart the service when it fails or signal the failure to the administrator.

Standard debugging steps

How to reproduce?

Expected behavior

Teleirc should return an exit code != 0 on error

Stacktrace

> systemctl status teleirc.service 
● teleirc.service - teleirc IRC-Telegram bridge
     Loaded: loaded (/nix/store/gfw26cvvsbr46rfaxxv3avkikm82hqrx-unit-teleirc.service/teleirc.service; enabled;>
     Active: inactive (dead) since Wed 2020-12-09 09:31:25 UTC; 14min ago
    Process: 22647 ExecStart=/nix/store/0l0cbi3xnivljrz1j77mwvbn7w8kxk5y-teleirc-2.0.1/bin/cmd -conf /nix/store/nadrd8p6nyv6x9k49prn26gn6qb8v22z>
   Main PID: 22647 (code=exited, status=0/SUCCESS)
         IP: 26.8K in, 5.4K out
        CPU: 90ms

Dec 09 09:31:24 nixos cmd[22647]: INFO: 2020/12/09 09:31:24 Current TeleIRC version: v2.0
Dec 09 09:31:24 nixos cmd[22647]: INFO: 2020/12/09 09:31:24 Creating new Telegram bot client...
Dec 09 09:31:24 nixos cmd[22647]: INFO: 2020/12/09 09:31:24 Creating new IRC bot client...
Dec 09 09:31:24 nixos cmd[22647]: INFO: 2020/12/09 09:31:24 Starting up Telegram bot...
Dec 09 09:31:24 nixos cmd[22647]: INFO: 2020/12/09 09:31:24 Starting up IRC bot...
Dec 09 09:31:25 nixos cmd[22647]: INFO: 2020/12/09 09:31:25 Authorized on account <snip>
Dec 09 09:31:25 nixos cmd[22647]: ERROR: 2020/12/09 09:31:25 EOF
Dec 09 09:31:25 nixos cmd[22647]: ERROR: 2020/12/09 09:31:25 EOF
Dec 09 09:31:25 nixos systemd[1]: teleirc.service: Succeeded.
Dec 09 09:31:25 nixos systemd[1]: teleirc.service: Consumed 90ms CPU time, received 26.6K IP traffic, sent 5.4K IP traffic.

Other details

this was on 2.0.1, not sure if it's fixed on 2.1, but I don't see anything relevant in the changelog

fgaz commented 3 years ago

Could someone triage this? Or point me to where errors are handled so I can prepare a PR fixing this?

Tjzabel commented 3 years ago

Hello,

There are many areas where logging and errors are handled throughout. It does seem we've handled errors incorrectly, and takes a bit further research to determine exactly where we went wrong. Any place we make use of the Logger, and more specifically logger.LogError is where you'd want to start looking to get to the bottom of this.