You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/10/17 12:33:41 UTC
[whimsy] 02/02: move activity watchdog to a separate thread
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git
commit e5cf10dca152bbf14a59439640fedcf324d68fbc
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Mon Oct 17 08:33:21 2016 -0400
move activity watchdog to a separate thread
---
www/board/agenda/daemon/wss.rb | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/www/board/agenda/daemon/wss.rb b/www/board/agenda/daemon/wss.rb
index 8c07df0..acef407 100755
--- a/www/board/agenda/daemon/wss.rb
+++ b/www/board/agenda/daemon/wss.rb
@@ -73,7 +73,7 @@ end
exit 0 if options.kill
########################################################################
-# Restart when source file changes #
+# Restart when source file changes or when inactive for an hour #
########################################################################
def restart_process
@@ -86,6 +86,16 @@ listener = Listen.to(__dir__) do |modified, added, removed|
end
listener.start
+active = Time.now
+
+# restart once an hour when inactive
+Thread.new do
+ loop do
+ sleep 90
+ restart_process if Time.now - active >= 3600
+ end
+end
+
########################################################################
# Close all open connection on exit #
########################################################################
@@ -108,14 +118,7 @@ if options.privkey and options.chain
}
end
-active = Time.now
-
EM.run do
- # restart once an hour when inactive
- EM.add_periodic_timer(900) do
- restart_process if Time.now - active >= 3600
- end
-
WebSocket::EventMachine::Server.start(server_options) do |ws|
ws.onclose do
Channel.delete ws
@@ -144,6 +147,7 @@ EM.run do
end
end
+ # reset activity timer
active = Time.now
end
end
--
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.