Sha256: c2b098325052e21ae03dcb858fad88138356b3f21a445700cdd9942a26b615ea
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
class SystemSetting < ActiveRecord::Base TIMEOUT = 20 def self.singleton system_setting = self.find(:first) if system_setting system_setting else self.new end end def exec "rake" # .bat on Windows end def update_gamespy self.gamespied_at = Time.now self.save cl = "sync:gamespy RAILS_ENV=#{ENV['RAILS_ENV']}" # + cl cl += " BASE_PATH=\'#{ENV['BASE_PATH']}\'" if ENV['BASE_PATH'] SixUpdaterWeb.run_program(exec, RAILS_ROOT, cl) end def update_gamespy_nogeo self.gamespied_at = Time.now self.save cl = "sync:gamespy RAILS_ENV=#{ENV['RAILS_ENV']} NOGEO=1" # + cl cl += " BASE_PATH=\'#{ENV['BASE_PATH']}\'" if ENV['BASE_PATH'] SixUpdaterWeb.run_program(exec, RAILS_ROOT, cl) end def synchronize Six::Network::Panel.setlogger(logger) l = [] begin status = Timeout::timeout(TIMEOUT) do Six::Network::Panel.login(self.server_username, self.server_password, true) end [Network, Mod, Server, Repository, Action, Appsetting, Sixconfig].each do |t| l += t.imp end rescue Timeout::Error logger.info "TIMEOUT while trying to synchronize!" rescue logger.info "ERROR: #{$!}" end l end def sync self.synchronized_at = Time.now self.save content = nil l = self.synchronize if l.size > 0 content = "Synchronized #{l.size} records with server-site!" #l.map {|e| e.to_json}.join(", ") else content = "WARNING: No objects received, possibly issue with connection (timeout?), or server site" end content end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
six-updater-web-0.13.4 | lib/app/models/system_setting.rb |