From 5a62ea42d24cb08ff84073ab37acb36a28f7c385 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 24 Apr 2019 00:41:03 -0500 Subject: [PATCH 1/2] Defaulting logging to journald in service file example --- example_services/egsbot.service | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example_services/egsbot.service b/example_services/egsbot.service index 0b7eece..2cb1a67 100644 --- a/example_services/egsbot.service +++ b/example_services/egsbot.service @@ -5,8 +5,9 @@ After=network.target [Service] User=ivo WorkingDirectory=/opt/skyfall/egs-bot -StandardOutput=file:/var/log/skyfall/egs-bot/run.log -StandardError=file:/var/log/skyfall/egs-bot/error.log +# Uncomment these for logging to flat files instead of journald +#StandardOutput=file:/var/log/skyfall/egs-bot/run.log +#StandardError=file:/var/log/skyfall/egs-bot/error.log PIDFile=/var/run/skyfall/egsbot.pid ExecStart=/usr/bin/ruby /opt/skyfall/egs-bot/run.rb SuccessExitStatus=SIGKILL From cb3c0d69d5d5b50e953d6ed5aa6d4fd4d61df603 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 24 Apr 2019 00:41:53 -0500 Subject: [PATCH 2/2] Better output and logging, round 2 --- commands.rb | 15 ++++++++++++--- patchnotes.txt | 6 ++++++ run.rb | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/commands.rb b/commands.rb index 72bf226..f5b71b1 100644 --- a/commands.rb +++ b/commands.rb @@ -71,11 +71,20 @@ end def process_command_srvstatus(message, command, adm) if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) telnet = @conf['telnet'] - if `nc -zvw3 #{telnet['host']} #{telnet['port']}` - puts 'Server responded. Fetching details...' - `./scripts/srvstatus.receipt #{@conf['token']} #{message.chat.id}` + print 'Checking connectivity to Empyrion service... ' + STDOUT.flush + if `nc -zvw3 #{telnet['host']} #{telnet['port']} >/dev/null 2>&1` + print "Server responded!\nSending message receipt... " STDOUT.flush + if `./scripts/srvstatus.receipt #{@conf['token']} #{message.chat.id}` + print "Receipt sent!\nFetching details...\n" + else + print "Receipt FAILED to send (non-zero exit code on scripts/srvstatus.receipt) !!!\nContinuing to fetch details anyway...\n" + end + else + print "Server did not respond! Passing to scripts/srvstatus for sending the failure message (revisit this for code efficiency review\n)" end + STDOUT.flush reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}` else reply = "Refusal: I am not authorized to provide this information here." diff --git a/patchnotes.txt b/patchnotes.txt index 7564ea2..50e56a8 100644 --- a/patchnotes.txt +++ b/patchnotes.txt @@ -1,5 +1,11 @@ +SkyfallTech EGS Telebot Patch Notes: +v0.3.02 ++ Better server logs, round 2 ++ Less ambiguous patchnotes listing + (These are for the bot, not for Empyrion) + v0.3.01 + Better server logs, round 1. diff --git a/run.rb b/run.rb index 1eae39d..9538d6b 100755 --- a/run.rb +++ b/run.rb @@ -155,6 +155,7 @@ def handle_message(message) else reply = "Mockery: My name is #{message.from.username}, I am a meatbag, and I think #{command} is a valid command." end + # Verbose output: puts "Sending #{reply.inspect}\n\n" #puts "End of case" return reply