|
@@ -1,3 +1,5 @@
|
|
|
+# rubocop:disable Rails/TimeZone
|
|
|
+
|
|
|
require 'json'
|
|
|
require 'session_helper'
|
|
|
|
|
@@ -33,7 +35,7 @@ returns
|
|
|
session_file = "#{path_tmp}/session"
|
|
|
|
|
|
# collect session data
|
|
|
- meta[:last_ping] = Time.zone.now.to_i.to_s
|
|
|
+ meta[:last_ping] = Time.now.utc.to_i.to_s
|
|
|
data = {
|
|
|
user: session,
|
|
|
meta: meta,
|
|
@@ -189,7 +191,7 @@ returns
|
|
|
list_of_closed_sessions = []
|
|
|
clients = Sessions.list
|
|
|
clients.each { |client_id, client|
|
|
|
- if !client[:meta] || !client[:meta][:last_ping] || ( client[:meta][:last_ping].to_i + idle_time_in_sec ) < Time.zone.now.to_i
|
|
|
+ if !client[:meta] || !client[:meta][:last_ping] || ( client[:meta][:last_ping].to_i + idle_time_in_sec ) < Time.now.utc.to_i
|
|
|
list_of_closed_sessions.push client_id
|
|
|
Sessions.destory( client_id )
|
|
|
end
|
|
@@ -213,7 +215,7 @@ returns
|
|
|
data = get(client_id)
|
|
|
return false if !data
|
|
|
path = "#{@path}/#{client_id}"
|
|
|
- data[:meta][:last_ping] = Time.zone.now.to_i.to_s
|
|
|
+ data[:meta][:last_ping] = Time.now.utc.to_i.to_s
|
|
|
content = data.to_json
|
|
|
File.open( path + '/session', 'wb' ) { |file|
|
|
|
file.write content
|
|
@@ -289,7 +291,7 @@ returns
|
|
|
|
|
|
def self.send( client_id, data )
|
|
|
path = "#{@path}/#{client_id}/"
|
|
|
- filename = "send-#{ Time.zone.now.to_f }"
|
|
|
+ filename = "send-#{ Time.now.utc.to_f }"
|
|
|
check = true
|
|
|
count = 0
|
|
|
while check
|
|
@@ -422,11 +424,11 @@ returns
|
|
|
def self.spool_create( msg )
|
|
|
path = "#{@path}/spool/"
|
|
|
FileUtils.mkpath path
|
|
|
- file_path = path + "/#{Time.zone.now.to_f}-#{rand(99_999)}"
|
|
|
+ file_path = path + "/#{Time.now.utc.to_f}-#{rand(99_999)}"
|
|
|
File.open( file_path, 'wb' ) { |file|
|
|
|
data = {
|
|
|
msg: msg,
|
|
|
- timestamp: Time.zone.now.to_i,
|
|
|
+ timestamp: Time.now.utc.to_i,
|
|
|
}
|
|
|
file.write data.to_json
|
|
|
}
|
|
@@ -457,7 +459,7 @@ returns
|
|
|
end
|
|
|
|
|
|
# ignore message older then 48h
|
|
|
- if spool['timestamp'] + (2 * 86_400) < Time.zone.now.to_i
|
|
|
+ if spool['timestamp'] + (2 * 86_400) < Time.now.utc.to_i
|
|
|
to_delete.push "#{path}/#{entry}"
|
|
|
next
|
|
|
end
|
|
@@ -568,7 +570,7 @@ returns
|
|
|
|
|
|
=end
|
|
|
|
|
|
- def self.thread_client(client_id, try_count = 0, try_run_time = Time.zone.now)
|
|
|
+ def self.thread_client(client_id, try_count = 0, try_run_time = Time.now.utc)
|
|
|
Rails.logger.debug "LOOP #{client_id} - #{try_count}"
|
|
|
begin
|
|
|
Sessions::Client.new(client_id)
|
|
@@ -586,10 +588,10 @@ returns
|
|
|
try_count += 1
|
|
|
|
|
|
# reset error counter if to old
|
|
|
- if try_run_time + ( 60 * 5 ) < Time.zone.now
|
|
|
+ if try_run_time + ( 60 * 5 ) < Time.now.utc
|
|
|
try_count = 0
|
|
|
end
|
|
|
- try_run_time = Time.zone.now
|
|
|
+ try_run_time = Time.now.utc
|
|
|
|
|
|
# restart job again
|
|
|
if try_run_max > try_count
|