koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
360 stars 65 forks source link

Updated ruby, now getting uninitialized constant ServerWatchdog::SourceServer (NameError) #325

Closed Fohdeesha closed 5 years ago

Fohdeesha commented 5 years ago

I have a small ruby script which uses steam-condenser to check on rcon output from a NMRIH server, and if it doesn't get any (the server has frozen) it resets the server. It has been working great until I updated ruby:

jon@games:~/objective$ ruby -v
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

Now when running it it thinks the server is always dead, and I get:

./watchdog.rb:23:in healthy?: uninitialized constant ServerWatchdog::SourceServer (NameError)

My script is here: https://github.com/Fohdeesha/game-servers/blob/master/NMRIH/Watchdog-Script/watchdog.rb

I completely removed the steam condenser gem, downloaded the latest ruby version from github (1.3.11) and reinstalled it, no change

koraktor commented 5 years ago

Using the archive from GitHub would require changes to the load path.

The gem should work as expected. The require should already fail, if the library cannot be found.

Fohdeesha commented 5 years ago

I was originally using steam-condenser by installing it from ruby's global gem repository, by just running the standard "gem install steam-condenser". However after I updated ruby a while ago, I started getting this error:

rcon_socket.rb:54:in connect: Object#timeout is deprecated, use Timeout.timeout instead.

So I went to your github to check if you had fixed it in the master branch, and indeed the master branch had 10 or so commits since the version that ruby has. So I uninstalled the version I got from ruby, and installed it using your latest code from github:

git clone https://github.com/koraktor/steam-condenser-ruby
cd steam-condenser-ruby
gem build steam-condenser.gemspec
gem install steam-condenser-1.3.11.gem

Now the timeout warning was gone, but I got a new warning, like my issue states:

./watchdog.rb:23:in healthy?: uninitialized constant ServerWatchdog::SourceServer (NameError)

Looking through your commits, I have found the issue. You did a lot of undocumented refactoring (and never bumped the version number either, so the majorly refactored version on github shows up as the same 1.3.11 version as you can get from ruby).

from this: https://github.com/koraktor/steam-condenser-ruby/blob/1.3-stable/lib/steam/servers/source_server.rb

to this: https://github.com/koraktor/steam-condenser-ruby/blob/master/lib/steam-condenser/servers/source_server.rb

So I changed my line from:

server = SourceServer.new(@ip,@port)

To:

server = SteamCondenser::Servers::SourceServer.new(@ip,@port)

To account for all the refactoring, as Servers is now a submodule of the SteamCondenser module, and now the error is gone.

koraktor commented 5 years ago

Version 2 has never been released due to Valve not finishing work on Steam Community‘s APIs and various partly undocumented changes on protocols in CS:GO and Dota 2.

You might as well continue to use 1.3.11 with Ruby 2.3+ despite the warning mentioned above.