@@ -20,7 +20,7 @@ class SessionManager < Hash
20
20
21
21
include Framework ::Offspring
22
22
23
- LAST_SEEN_INTERVAL = 60 * 2.5
23
+ LAST_SEEN_INTERVAL = 60 * 2.5
24
24
SCHEDULER_THREAD_COUNT = 5
25
25
26
26
def initialize ( framework )
@@ -98,12 +98,10 @@ def initialize(framework)
98
98
end
99
99
end
100
100
101
-
102
101
#
103
102
# Skip the database cleanup code below if there is no database
104
103
#
105
- next if not ( framework . db and framework . db . active and framework . db . is_local? )
106
-
104
+ next unless framework . db && framework . db . active && framework . db . is_local?
107
105
108
106
#
109
107
# Mark all open session as alive every LAST_SEEN_INTERVAL
@@ -114,6 +112,7 @@ def initialize(framework)
114
112
# processing time for large session lists from skewing our update interval.
115
113
116
114
last_seen_timer = Time . now . utc
115
+
117
116
if framework . db . active
118
117
::ActiveRecord ::Base . connection_pool . with_connection do
119
118
values . each do |s |
@@ -129,20 +128,12 @@ def initialize(framework)
129
128
end
130
129
end
131
130
132
-
133
131
#
134
132
# Clean out any stale sessions that have been orphaned by a dead
135
133
# framework instance.
136
134
#
137
- ::ActiveRecord ::Base . connection_pool . with_connection do |conn |
138
- ::Mdm ::Session . where ( closed_at : nil ) . each do |db_session |
139
- if db_session . last_seen . nil? or ( ( Time . now . utc - db_session . last_seen ) > ( 2 *LAST_SEEN_INTERVAL ) )
140
- db_session . closed_at = db_session . last_seen || Time . now . utc
141
- db_session . close_reason = "Orphaned"
142
- db_session . save
143
- end
144
- end
145
- end
135
+ framework . db . remove_stale_sessions ( LAST_SEEN_INTERVAL )
136
+
146
137
end
147
138
148
139
#
0 commit comments