forked from nesquena/gitdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the proper rescue handler for Restarts, which will properly call the retry and restart the Celluloid actors. Some additional changes: * extract the Celluloid actor handling to a facade class, so that the Manager is less responsible and easier to test * add a log error message check into the integration test
- Loading branch information
Showing
7 changed files
with
213 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# -*- encoding : utf-8 -*- | ||
|
||
module Gitdocs | ||
class CelluloidFascade | ||
# @param [String] host | ||
# @param [Integer] port | ||
def initialize(host, port) | ||
@host = host | ||
@port = port | ||
end | ||
|
||
# @return [void] | ||
def start | ||
Celluloid.boot unless Celluloid.running? | ||
@supervisor = Celluloid::SupervisionGroup.run! | ||
|
||
# Start the web server ################################################### | ||
app = | ||
Rack::Builder.new do | ||
use Rack::Static, | ||
urls: %w(/css /js /img /doc), | ||
root: File.expand_path('../public', __FILE__) | ||
use Rack::MethodOverride | ||
map('/settings') { run SettingsApp } | ||
map('/') { run BrowserApp } | ||
end | ||
@supervisor.add( | ||
Reel::Rack::Server, | ||
as: :reel_rack_server, | ||
args: [ | ||
app, | ||
{ | ||
Host: @host, | ||
Port: @port, | ||
quiet: true | ||
} | ||
] | ||
) | ||
|
||
# Start the synchronizers ################################################ | ||
Share.all.each do |share| | ||
@supervisor.add( | ||
Synchronizer, as: share.id.to_s, args: [share] | ||
) | ||
end | ||
|
||
# Start the repository listeners ######################################### | ||
@listener = | ||
Listen.to( | ||
*Share.paths, | ||
ignore: /#{File::SEPARATOR}\.git#{File::SEPARATOR}/ | ||
) do |modified, added, removed| | ||
all_changes = modified + added + removed | ||
changed_repository_paths = | ||
Share.paths.select do |directory| | ||
all_changes.any? { |x| x.start_with?(directory) } | ||
end | ||
|
||
changed_repository_paths.each do |directory| | ||
actor_id = Share.find_by_path(directory).id.to_s | ||
Celluloid::Actor[actor_id].async.synchronize | ||
end | ||
end | ||
@listener.start | ||
end | ||
|
||
# @return [void] | ||
def terminate | ||
@listener.stop if @listener | ||
@supervisor.terminate if @supervisor | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- encoding : utf-8 -*- | ||
|
||
require File.expand_path('../test_helper', __FILE__) | ||
|
||
describe 'Gitdocs::CelluloidFacade' do | ||
let(:celluloid_facade) { Gitdocs::CelluloidFacade.new(:host, :port) } | ||
|
||
# TODO: describe '#start' do | ||
|
||
# TODO: describe '#terminate' do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters