Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
126 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--format progress |
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,28 @@ | ||
module Daemons | ||
module Rails | ||
class Controller | ||
attr_reader :path, :app_name | ||
|
||
def initialize(controller_path) | ||
@path = controller_path | ||
@app_name = "#{controller_path.basename.to_s[0..-'_ctrl'.length]}.rb" | ||
end | ||
|
||
def run(command) | ||
`#{path} #{command}` | ||
end | ||
|
||
def start | ||
run('start') | ||
end | ||
|
||
def stop | ||
run('stop') | ||
end | ||
|
||
def status | ||
run('status').to_s.split("\n").last =~ /: running \[pid \d+\]$/ ? :running : :not_exists | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Daemons | ||
module Rails | ||
VERSION = "0.0.3" | ||
VERSION = "1.0.0" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dir_mode: script | ||
dir: "../../log" | ||
multiple: false | ||
backtrace: true | ||
monitor: false | ||
ontop: false |
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 @@ | ||
#Test script |
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 @@ | ||
# Test controller |
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,37 @@ | ||
require "spec_helper" | ||
require "daemons/rails/monitoring" | ||
require "ostruct" | ||
|
||
describe Daemons::Rails::Monitoring do | ||
subject { Daemons::Rails::Monitoring } | ||
|
||
it "should get list of controllers" do | ||
controllers = subject.controllers | ||
controllers.should have(1).item | ||
controller = controllers[0] | ||
controller.path.should == Rails.root.join('lib', 'daemons', 'test_ctl') | ||
controller.app_name.should == 'test.rb' | ||
end | ||
|
||
describe "using controllers" do | ||
before :each do | ||
@controller = Daemons::Rails::Controller.new(Rails.root.join('lib', 'daemons', 'test_ctl')) | ||
subject.stub(:controllers).and_return([@controller]) | ||
end | ||
|
||
it "should return status for all controllers" do | ||
@controller.should_receive(:run).with('status').and_return('test.rb: running [pid 10880]') | ||
subject.statuses.should == {'test.rb' => :running} | ||
end | ||
|
||
it "should start controller by name" do | ||
@controller.should_receive(:run).with('start') | ||
subject.start('test.rb') | ||
end | ||
|
||
it "should stop controller by name" do | ||
@controller.should_receive(:run).with('stop') | ||
subject.stop('test.rb') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Rails | ||
def Rails.root | ||
@root ||= Pathname.new(File.absolute_path(File.dirname(__FILE__))).join('fixtures') | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.treat_symbols_as_metadata_keys_with_true_values = true | ||
config.run_all_when_everything_filtered = true | ||
config.filter_run :focus | ||
end |