luvit/luvit

Console (Cmd Line) Goes Inactive over time

Closed this issue · 15 comments

I may be dumb and not used to using tools like this but my console always goes inactive over a period of time on my computer which initiates the bot. I'm running Windows 10 and currently not to sure how to fix this, does anybody have any advice to keep this bot activly monitoring Discord channels?

Assuming you're using Discordia, you might have more luck asking somewhere more Discordia-specific:

Assumption correct, so Discordia could be the problem? I currently start by doing on cmd line in the directory of luvit
"luvit bot.lua"

The possible reasons it stops:

  • The libuv loop runs out of events to process and it exits without an error
  • Some unhandled error happens and it prints a stack trace and exits
  • Some underlying error happens (segfault or something) and the process exits unexpectedly without a Lua stack trace

My guess would be you're running into the first bullet point, and if so, then the fix would be specific to your code/Discordia.

A simple example of what I said in my previous comment:

This will run forever:

local timer = require('timer')

print("Starting 1000ms interval")
local interval = timer.setInterval(1000, function ()
  print("on_interval")
end)

This will print "on_interval" once and then exit the process (because the libuv event loop has nothing left to do):

local timer = require('timer')

local interval
print("Starting 1000ms interval")
interval = timer.setInterval(1000, function ()
  print("on_interval")
  timer.clearInterval(interval)
end)

So that SHOULD technically keep the console from exiting out without interupting client:on to capture messages sent?

Really my only issue with Luvit is that it inactivates every so often but tomorrow I can test that to see if it's a solution

By any chance do you have Discord and willing to help me out tomorrow if I have issues? @squeek502

If so my Discord is NotInTheBand#0666

That was just an example of the type of thing that could be happening, not a solution. If your process is exiting when it shouldn't be, and it's not printing an error, then it's either:

  • Stopped on its own (like the example code posted above), in which case it is a problem with your code or with Discordia, not with Luvit. You'll probably want to get help in the Discordia discord server (linked above).
  • Crashed somewhere in the C code, in which case it will be difficult to debug. Hopefully this is not what is happening.

To give you a more detailed error, if I just leave the thing overnight, when I return and type a command I designed such as !clean which removes the first 10 lines of shit in the channel sent, it will pend until I just select the console window and every key I type will advance it in a step in the command sent, as if each key request sends another command from code.

It WILL function after I just press RANDOM ASCII key's in the console window

Ok, that's a different problem than I thought you were having. It sounds like your process is still running, it just doesn't behave right (if your Luvit process stopped, then your Discord bot would be offline). Definitely seems like a Discordia-specific thing, try asking for help there.

I def will tomorrow, thanks for the direction @squeek502 !

Old issue, but relevant to my interests. Were you able to figure out what was wrong @NotInTheBand ?

I believe I did fix it but I can't actually remember how. It had something to do with the actual Cmd Prompt settings, not sure if it is in WIndows 7 and 8.1 but it was a default setting in 10 which caused it.

That's okay. Just cleaning up some old issues.