Class: SystemSetting
Constant Summary
collapse
- TIMEOUT =
20
Class Method Summary
collapse
Instance Method Summary
collapse
#associated_valid?, #no_errors_in_associated?, #save_associated, #save_associated!, #save_with_unsaved_flag, #to_label, #unsaved=, #unsaved?
Class Method Details
.singleton ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/six-updater-web/app/models/system_setting.rb', line 4
def self.singleton
system_setting = self.find(:first)
if system_setting
system_setting
else
self.new
end
end
|
Instance Method Details
13
14
15
|
# File 'lib/six-updater-web/app/models/system_setting.rb', line 13
def exec
"rake" end
|
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/six-updater-web/app/models/system_setting.rb', line 97
def sync
self.synchronized_at = Time.now
self.save
l = self.synchronize
self.update_sitecontrollers
content = l.size > 0 ? "Synchronized #{l.size} records with server-site!" : "WARNING: No objects received, possibly issue with connection (timeout?), or server site"
content
end
|
#synchronize ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/six-updater-web/app/models/system_setting.rb', line 49
def synchronize
l = []
begin
Six::Network::Panel.setlogger(logger)
status = Timeout::timeout(TIMEOUT) do
Six::Network::Panel.login(self.server_username, self.server_password, true)
end
begin
l += Category.imp
rescue => e
logger.error "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
end
[Mod, Network, Server, Repository, Action, Appsetting, Sixconfig].each do |t|
r = t.imp
begin
r.each do |mod|
if mod.dependencies && !mod.dependencies.empty?
mod.mods = mod.dependencies.map{|m| Mod.find(:first, :conditions => ["name LIKE ?", m]) }.reject{|m| m.nil?}
mod.save
end
end
rescue => e
logger.error "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
end if t == Mod
l += r
end
rescue Timeout::Error
logger.info "TIMEOUT while trying to synchronize!"
rescue => e
logger.info "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
end
l
end
|
#update_gamespy(setting = Appsetting.new, internal = false) ⇒ Object
#update_gamespy_nogeo(setting = Appsetting.new, internal = false) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/six-updater-web/app/models/system_setting.rb', line 36
def update_gamespy_nogeo(setting = Appsetting.new, internal = false)
self.gamespied_at = Time.now
self.save
ENV['NOGEO'] = "1"
if internal
SixUpdaterWeb.update_gamespy
else
cl = "sync:gamespy RAILS_ENV=#{ENV['RAILS_ENV']} NOGEO=1 GAMESPY_TYPES=#{setting.edition::GAMESPY_TYPES.join(",")}" cl += " BASE_PATH=\'#{SixUpdaterWeb::BASE_PATH}\'" if defined?(SixUpdaterWeb::OLDLOCATION)
SixUpdaterWeb.run_program(exec, RAILS_ROOT, cl)
end
end
|
#update_sitecontrollers ⇒ Object
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/six-updater-web/app/models/system_setting.rb', line 86
def update_sitecontrollers
if ENV["RAILS_ENV"] == "production" && (RUBY_VERSION > "1.9.1" || RUBY_VERSION < "1.9.1")
begin
SixUpdaterWeb.update_site_controllers rescue => e
logger.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
end
end
end
|