Starting snapshot thread on first HTTP request (otherwise, --daemon option fails); ticket:48, ticket:198
This commit is contained in:
parent
adc6b005d5
commit
6578bed720
|
@ -2,7 +2,7 @@
|
||||||
# Likewise will all the methods added be available for all controllers.
|
# Likewise will all the methods added be available for all controllers.
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
before_filter :set_utf8_http_header, :connect_to_model
|
before_filter :set_utf8_http_header, :connect_to_model, :check_snapshot_thread
|
||||||
after_filter :remember_location
|
after_filter :remember_location
|
||||||
|
|
||||||
# For injecting a different wiki model implementation. Intended for use in tests
|
# For injecting a different wiki model implementation. Intended for use in tests
|
||||||
|
@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def authorized?
|
def authorized?
|
||||||
@web.nil? ||
|
@web.nil? ||
|
||||||
@web.password.nil? ||
|
@web.password.nil? ||
|
||||||
cookies['web_address'] == @web.password ||
|
cookies['web_address'] == @web.password ||
|
||||||
password_check(@params['password'])
|
password_check(@params['password'])
|
||||||
end
|
end
|
||||||
|
@ -34,6 +34,10 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_snapshot_thread
|
||||||
|
WikiService.check_snapshot_thread
|
||||||
|
end
|
||||||
|
|
||||||
def connect_to_model
|
def connect_to_model
|
||||||
@action_name = @params['action'] || 'index'
|
@action_name = @params['action'] || 'index'
|
||||||
@web_name = @params['web']
|
@web_name = @params['web']
|
||||||
|
|
|
@ -152,6 +152,11 @@ class WikiService
|
||||||
def snapshot
|
def snapshot
|
||||||
@madeleine.snapshot
|
@madeleine.snapshot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_snapshot_thread
|
||||||
|
# @madeleine may not be initialised in unit tests, and in such case there is no need to do anything
|
||||||
|
@madeleine.check_snapshot_thread unless @madeleine.nil?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -185,7 +190,7 @@ class MadeleineServer
|
||||||
Madeleine::ZMarshal.new) {
|
Madeleine::ZMarshal.new) {
|
||||||
service.new
|
service.new
|
||||||
}
|
}
|
||||||
start_snapshot_thread
|
@snapshoot_thread_running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def command_log_present?
|
def command_log_present?
|
||||||
|
@ -196,7 +201,12 @@ class MadeleineServer
|
||||||
@server.take_snapshot
|
@server.take_snapshot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_snapshot_thread
|
||||||
|
start_snapshot_thread unless @snapshoot_thread_running
|
||||||
|
end
|
||||||
|
|
||||||
def start_snapshot_thread
|
def start_snapshot_thread
|
||||||
|
@snapshoot_thread_running = true
|
||||||
Thread.new(@server) {
|
Thread.new(@server) {
|
||||||
hours_since_last_snapshot = 0
|
hours_since_last_snapshot = 0
|
||||||
while true
|
while true
|
||||||
|
|
Loading…
Reference in a new issue