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.
Merge pull request nesquena#131 from acant/bug/restart
Fixing crash on configuration restarts through the web UI
- Loading branch information
Showing
10 changed files
with
222 additions
and
89 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
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
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
Oops, something went wrong.